Skip to content

Commit

Permalink
static & media files update
Browse files Browse the repository at this point in the history
  • Loading branch information
Nar0kan committed Jul 4, 2023
1 parent 93917b2 commit 093f6be
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 23 deletions.
70 changes: 63 additions & 7 deletions ingotcrm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
DEBUG = env('DEBUG')
SECRET_KEY = env('SECRET_KEY')

ALLOWED_HOSTS = ['.vercel.app']
ALLOWED_HOSTS = ['127.0.0.1', '.vercel.app']

# Application definition

INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
'leads',
'agents',
'ecom.apps.EcomConfig',

'whitenoise.runserver_nostatic',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -135,13 +135,10 @@
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

LOGIN_REDIRECT_URL = "/leads"

LOGIN_URL = "/login"

LOGOUT_REDIRECT_URL = "/"

CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind"

CRISPY_TEMPLATE_PACK = "tailwind"

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
Expand All @@ -154,7 +151,66 @@

# For django-paypal
PAYPAL_TEST = True

PAYPAL_RECEIVER_EMAIL = env('PAYPAL_RECEIVER_EMAIL')

PAYPAL_RECEIVER_ID = env('PAYPAL_RECEIVER_ID')

# AWS Bucket
# AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
# AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
# AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME')
# AWS_S3_SIGNATURE_NAME = 's3v4',
# AWS_S3_REGION_NAME = 'eu-north-1'
# AWS_S3_FILE_OVERWRITE = False
# AWS_DEFAULT_ACL = None
# AWS_S3_VERITY = True
# DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
# STORAGES = {"default": {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage"}}
# AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'

# s3 static settings
# STATIC_LOCATION = 'static'
# STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{STATIC_LOCATION}/'
# STATICFILES_STORAGE = 'hello_django.storage_backends.StaticStorage'

# s3 public media settings
# PUBLIC_MEDIA_LOCATION = 'media'
# MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/'
# DEFAULT_FILE_STORAGE = 'ingotcrm.storage_backends.PublicMediaStorage'

# s3 private media settings
# PRIVATE_MEDIA_LOCATION = 'private'
# PRIVATE_FILE_STORAGE = 'hello_django.storage_backends.PrivateMediaStorage'

# For debug purposes
# LOGGING = {
# 'version': 1,
# 'disable_existing_loggers': False,
# 'formatters': {
# 'verbose': {
# 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
# 'datefmt' : "%d/%b/%Y %H:%M:%S"
# },
# 'simple': {
# 'format': '%(levelname)s %(message)s'
# },
# },
# 'handlers': {
# 'file': {
# 'level': 'DEBUG',
# 'class': 'logging.FileHandler',
# 'filename': 'mysite.log',
# 'formatter': 'verbose'
# },
# },
# 'loggers': {
# 'django': {
# 'handlers':['file'],
# 'propagate': True,
# 'level':'DEBUG',
# },
# 'MYAPP': {
# 'handlers': ['file'],
# 'level': 'DEBUG',
# },
# }
# }
15 changes: 15 additions & 0 deletions ingotcrm/storage_backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from storages.backends.s3boto3 import S3Boto3Storage
from django.conf import settings


class PublicMediaStorage(S3Boto3Storage):
location = 'media'
default_acl = 'public-read'
file_overwrite = False


# class PrivateMediaStorage(S3Boto3Storage):
# location = 'private'
# default_acl = 'private'
# file_overwrite = False
# custom_domain = False
4 changes: 4 additions & 0 deletions ingotcrm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
)
from django.conf.urls.static import static

from django.views.static import serve
from django.urls import re_path as url


urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -36,6 +39,7 @@
path('donate/', DonateView, name='donate'),
path('paypal/', include('paypal.standard.ipn.urls')),
path('ecom/', include('ecom.urls')),
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]

handler404 = 'leads.views.Error404View'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
altgraph==0.17.3
asgiref==3.6.0
boto3==1.27.0
botocore==1.30.0
certifi==2023.5.7
charset-normalizer==3.1.0
crispy-tailwind==0.5.0
Expand All @@ -9,19 +11,25 @@ django-environ==0.9.0
django-filter==22.1
django-jquery==3.1.0
django-paypal==2.0
django-storages==1.13.2
future==0.18.3
idna==3.4
jmespath==1.0.1
libmagic==1.0
pefile==2023.2.7
Pillow==9.4.0
psycopg2-binary==2.9.6
pyinstaller==5.8.0
pyinstaller-hooks-contrib==2023.0
pyperclip==1.8.2
python-dateutil==2.8.2
pytz==2022.7
pywin32-ctypes==0.2.0
requests==2.31.0
s3transfer==0.6.1
six==1.16.0
sqlparse==0.4.3
tk==0.1.0
tzdata==2022.7
urllib3==2.0.3
urllib3==1.26.16
whitenoise==6.5.0
2 changes: 1 addition & 1 deletion static_root/staticfiles.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions templates/category_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<a href="{% url 'leads:lead-detail' lead.pk %}">
<li class="flex pb-5 pt-5 ml-5 py-4 first:pt-0 last:pb-0 hover:border-l-2 hover:border-blue-300 mb-3 px-5">
{% if lead.photo %}
<img src="{{ lead.photo.url }}" alt="{% static 'images\UserPhoto.jpg' %}" class="h-12 w-12" style="border-radius: 50%;"/>
<img src="{{ lead.photo.url }}" alt="{% static 'images/UserPhoto.jpg' %}" class="h-12 w-12" style="border-radius: 50%;"/>
{% else %}
<img src="{% static 'images\UserPhoto.jpg' %}" alt="Photo" class="h-12 w-12" style="border-radius: 50%;"/>
<img src="{% static 'images/UserPhoto.jpg' %}" alt="Photo" class="h-12 w-12" style="border-radius: 50%;"/>
{% endif %}

<div class="ml-3 overflow-hidden">
Expand Down
6 changes: 3 additions & 3 deletions templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="mb-6 md:mb-0">
<p>
<a href="{% url 'landing-page' %}" class="inline-flex items-center">
<img src="{% static 'images\logo.png' %}" class="h-8 mr-3" alt="Logo" />
<img src="{% static 'images/logo.png' %}" class="h-8 mr-3" alt="Logo" />
<span class="self-center text-2xl font-semibold whitespace-nowrap text-white">IngotCRM</span>
</a>
</p>
Expand Down Expand Up @@ -54,11 +54,11 @@ <h2 class="mb-6 text-sm font-semibold text-gray-100 uppercase dark:text-white">L
<a href="{% url 'donate' %}" class="inline-block text-sm font-semibold text-gray-100 dark:text-white hover:text-blue-200 focus:ring-4 focus:ring-primary-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center text-black hover:bg-[#DBA39A] font-semibold dark:text-white border-2 border-gray-500 dark:border-[#404258] round dark:hover:bg-gray-600 px-5 py-2">Support us</a>
<div class="flex mt-4 space-x-6 sm:justify-center sm:mt-0">
<a href="https://www.linkedin.com/in/nikita-kirichenko-781062251/" class="text-gray-200 hover:text-gray-900 dark:hover:text-white" target="_blank">
<img class="w-10 h-10" fill="currentColor" src="{% static 'images\linkedin.svg' %}" viewBox="0 0 24 24" aria-hidden="true"/>
<img class="w-10 h-10" fill="currentColor" src="{% static 'images/linkedin.svg' %}" viewBox="0 0 24 24" aria-hidden="true"/>
<span class="sr-only">Linkedin page</span>
</a>
<a href="https://github.com/Nar0kan/" class="text-gray-200 hover:text-gray-900 dark:hover:text-white" target="_blank">
<img class="w-10 h-10" fill="currentColor" src="{% static 'images\github.svg' %}" viewBox="0 0 24 24" aria-hidden="true"/>
<img class="w-10 h-10" fill="currentColor" src="{% static 'images/github.svg' %}" viewBox="0 0 24 24" aria-hidden="true"/>
<span class="sr-only">GitHub account</span>
</a>
<p class="text-gray-400"> icons by <a target="_blank" href="https://icons8.com">Icons8</a></p>
Expand Down
12 changes: 6 additions & 6 deletions templates/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h1 class="max-w-2xl mb-4 text-xl font-extrabold tracking-tight leading-none md:
{% endif %}
</div>
<div class="hidden lg:mt-0 lg:col-span-5 lg:flex md:w-128 md:h-128 mg:w-64 mg:h-64 transition-all duration-300 rounded-lg blur-sm hover:blur-none">
<img src="{% static 'images\ops.png' %}" alt="documents.png">
<img src="{% static 'images/ops.png' %}" alt="documents.png">
</div>
</div>
</section>
Expand All @@ -195,7 +195,7 @@ <h2 class="text-3xl font-bold mb-12">
<a href="https://www.python.org/" target="_blank">
<div class="mb-12">
<img
src="{% static 'images\python.svg' %}"
src="{% static 'images/python.svg' %}"
class="bg-fixed opacity-80 transition duration-300 ease-in-out hover:opacity-100 px-6"
alt="Python - logo"
/>
Expand All @@ -204,7 +204,7 @@ <h2 class="text-3xl font-bold mb-12">
<a href="https://www.djangoproject.com/" target="_blank">
<div class="mb-12">
<img
src="{% static 'images\django.svg' %}"
src="{% static 'images/django.svg' %}"
class="bg-fixed opacity-80 transition duration-300 ease-in-out hover:opacity-100 px-6"
alt="Django - logo"
/>
Expand All @@ -213,7 +213,7 @@ <h2 class="text-3xl font-bold mb-12">
<a href="https://tailwindcss.com/" target="_blank">
<div class="mb-12 md:mb-0">
<img
src="{% static 'images\tailwind.svg' %}"
src="{% static 'images/tailwind.svg' %}"
class="bg-fixed opacity-80 transition duration-300 ease-in-out hover:opacity-100 px-6"
alt="Tailwind - logo"
/>
Expand All @@ -222,7 +222,7 @@ <h2 class="text-3xl font-bold mb-12">
<a href="https://uk.wikipedia.org/wiki/HTML5" target="_blank">
<div class="mb-12">
<img
src="{% static 'images\html.svg' %}"
src="{% static 'images/html.svg' %}"
class="bg-fixed opacity-80 transition duration-300 ease-in-out hover:opacity-100 px-6"
alt="HTML - logo"
/>
Expand All @@ -233,7 +233,7 @@ <h2 class="text-3xl font-bold mb-12">
</div>
<div class="md:mb-12 lg:mb-0">
<img
src="{% static 'images\logo.png' %}"
src="{% static 'images/logo.png' %}"
class="w-full rounded-lg shadow-lg"
alt="Site - logo"
/>
Expand Down
4 changes: 2 additions & 2 deletions templates/lead_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="" data-carousel="static">
<a href="{% url 'leads:assign-agent' lead.pk %}">
<li class="flex mt-3 mb-3 py-4 first:pt-0 last:pb-0">
<img src="{% static 'images\UserPhoto.jpg' %}" class="h-12 w-12" alt="Standart profile photo" style="border-radius: 50%;"/>
<img src="{% static 'images/UserPhoto.jpg' %}" class="h-12 w-12" alt="Standart profile photo" style="border-radius: 50%;"/>
<div class="ml-3 overflow-hidden">
<p class="text-sm font-medium text-slate-900">
<h3>{{ lead.first_name }} {{ lead.last_name }}</h3>
Expand All @@ -58,7 +58,7 @@ <h5 class="ml-12 text-sm text-slate-500 dark:text-slate-300">Created at {{ lead.
{% if lead.photo %}
<img src="{{ lead.photo.url }}" alt="{{lead.first_name}} {{lead.last_name}} profile" class="h-12 w-12" alt="Custom profile photo" style="border-radius: 50%;"/>
{% else %}
<img src="{% static 'images\UserPhoto.jpg' %}" alt="Standart static profile" alt="Standart profile photo" class="h-12 w-12" style="border-radius: 50%;"/>
<img src="{% static 'images/UserPhoto.jpg' %}" alt="Standart static profile" alt="Standart profile photo" class="h-12 w-12" style="border-radius: 50%;"/>
{% endif %}
</a>
<div class="ml-3 overflow-hidden">
Expand Down
2 changes: 1 addition & 1 deletion templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- Left side elements -->
<div class="col-span-2">
<a href="{% url 'landing-page' %}" class="flex items-center">
<img src="{% static 'images\logo.png' %}" class="h-6 mr-3 sm:h-10 rounded-full" alt="logo" />
<img src="{% static 'images/logo.png' %}" class="h-6 mr-3 sm:h-10 rounded-full" alt="logo" />
<span class="self-center text-xl font-semibold whitespace-nowrap text-white">Ingot CRM</span>
</a>
<button data-collapse-toggle="navbar-dropdown" type="button" class="inline-flex items-center p-2 ml-3 text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-dropdown" aria-expanded="false">
Expand Down

0 comments on commit 093f6be

Please sign in to comment.