generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/ita-social-projects/Forum …
…into #764-Banner/Logo-update-with-previously-approved-content
- Loading branch information
Showing
38 changed files
with
567 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import os | ||
from celery import Celery | ||
from celery.schedules import crontab | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "forum.settings") | ||
app = Celery("forum") | ||
|
||
app.config_from_object("django.conf:settings", namespace="CELERY") | ||
|
||
app.autodiscover_tasks() | ||
|
||
app.conf.beat_schedule = { | ||
"every": { | ||
"task": "images.tasks.celery_send_email_images", | ||
"schedule": crontab(day_of_month="1"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,6 @@ | |
"search", | ||
"drf_spectacular", | ||
"images", | ||
"forum.apps.ForumConfig", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
@@ -238,7 +237,6 @@ def show_toolbar(request): | |
"SHOW_TOOLBAR_CALLBACK": show_toolbar, | ||
} | ||
|
||
|
||
LOGGING = { | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
|
@@ -268,3 +266,10 @@ def show_toolbar(request): | |
}, | ||
}, | ||
} | ||
|
||
CONTACTS_INFO = { | ||
"email": "[email protected]", | ||
"phone": "+38 050 234 23 23", | ||
"university": "Львівська Політехніка", | ||
"address": "вул. Степана Бандери 12, Львів", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from celery import shared_task | ||
from datetime import timedelta | ||
|
||
from django.db.models import Sum, Count | ||
from django.utils import timezone | ||
|
||
from utils.images.send_email import send_email_about_banners_and_logos | ||
from .models import ProfileImage | ||
|
||
|
||
@shared_task() | ||
def celery_send_email_images(): | ||
now = timezone.now() | ||
photos = ProfileImage.objects.filter( | ||
created_at__gte=now - timedelta(days=30) | ||
) | ||
logo_data = photos.filter(image_type=ProfileImage.LOGO).aggregate( | ||
total_size=Sum("image_size"), count=Count("uuid") | ||
) | ||
banner_data = photos.filter(image_type=ProfileImage.BANNER).aggregate( | ||
total_size=Sum("image_size"), count=Count("uuid") | ||
) | ||
|
||
logo_total_size_kb = round(logo_data["total_size"] / 1024, 2) | ||
banner_total_size_kb = round(banner_data["total_size"] / 1024, 2) | ||
|
||
send_email_about_banners_and_logos( | ||
banner_data["count"], | ||
logo_data["count"], | ||
banner_total_size_kb, | ||
logo_total_size_kb, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="uk"> | ||
<head> | ||
<style> | ||
body { | ||
color: black; | ||
font-family: Arial, sans-serif; | ||
} | ||
p, b { | ||
color: black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<img src="{{protocol}}://178.212.110.52/craftMerge-logo.png" alt="CRAFTMERGE"/> | ||
<p>Доброго дня,</p> | ||
<p>Кількість банерів: {{ num_of_banners }} Загальний розмір: {{ size_of_banners }} Кб</p> | ||
<p>Кількість логотипів: {{ num_of_logos }} Загальний розмір: {{ size_of_logos }} Кб</p> | ||
|
||
<p>З повагою,</p> | ||
<p>Команда CraftMerge</p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from decouple import config | ||
from django.conf import settings | ||
from django.core.mail import EmailMultiAlternatives | ||
from django.template.loader import render_to_string | ||
|
||
from administration.models import ModerationEmail | ||
|
||
EMAIL_CONTENT_SUBTYPE = "html" | ||
PROTOCOL = "http" | ||
DOMAIN = config("ALLOWED_ENV_HOST") | ||
|
||
|
||
def set_admin_email(): | ||
instance = ModerationEmail.objects.first() | ||
if instance: | ||
email = instance.email_moderation | ||
else: | ||
email = settings.EMAIL_HOST_USER | ||
return email | ||
|
||
|
||
def send_email_about_banners_and_logos( | ||
num_of_banners, num_of_logos, size_of_banners_kb, size_of_logos_kb | ||
): | ||
context = { | ||
"protocol": PROTOCOL, | ||
"num_of_banners": num_of_banners, | ||
"num_of_logos": num_of_logos, | ||
"size_of_banners": size_of_banners_kb, | ||
"size_of_logos": size_of_logos_kb, | ||
} | ||
|
||
recipient = set_admin_email() | ||
email_body = render_to_string("images/email_template.html", context) | ||
email = EmailMultiAlternatives( | ||
subject="Information about number and size of banners and logos", | ||
body=email_body, | ||
from_email=settings.EMAIL_HOST_USER, | ||
to=[ | ||
recipient, | ||
], | ||
) | ||
|
||
email.content_subtype = EMAIL_CONTENT_SUBTYPE | ||
email.send(fail_silently=False) |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,7 @@ | ||
.App { | ||
/*for footer correct work*/ | ||
min-height: 100vh; | ||
flex-direction: column; | ||
width: var(--main-block-size); | ||
display: flex; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
|
||
to { | ||
transform: rotate(360deg); | ||
} | ||
} |
Oops, something went wrong.