init
This commit is contained in:
56
backend/config/services/celery.py
Normal file
56
backend/config/services/celery.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Celery application configuration and scheduling."""
|
||||
|
||||
import os
|
||||
|
||||
from celery import Celery
|
||||
from celery.schedules import crontab
|
||||
from decouple import config
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.development')
|
||||
|
||||
app = Celery('config')
|
||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
app.autodiscover_tasks()
|
||||
|
||||
app.conf.update(
|
||||
broker_url=config('REDIS_URL', default='redis://localhost:6379/0'),
|
||||
result_backend=config('REDIS_URL', default='redis://localhost:6379/0'),
|
||||
task_serializer='json',
|
||||
accept_content=['json'],
|
||||
result_serializer='json',
|
||||
timezone='UTC',
|
||||
enable_utc=True,
|
||||
task_track_started=True,
|
||||
task_time_limit=30 * 60,
|
||||
task_soft_time_limit=60,
|
||||
worker_prefetch_multiplier=1,
|
||||
worker_max_tasks_per_child=1000,
|
||||
)
|
||||
|
||||
app.conf.beat_schedule = {
|
||||
'send-event-reminders': {
|
||||
'task': 'communications.tasks.send_event_reminders',
|
||||
'schedule': crontab(minute=0, hour='*/1'),
|
||||
'description': 'Runs hourly to notify about upcoming events.',
|
||||
},
|
||||
'send-weekly-newsletter': {
|
||||
'task': 'communications.tasks.send_weekly_newsletter',
|
||||
'schedule': crontab(hour=9, minute=0, day_of_week=1),
|
||||
'description': 'Runs every Monday at 09:00 UTC.',
|
||||
},
|
||||
'cleanup-expired-tokens': {
|
||||
'task': 'communications.tasks.cleanup_expired_tokens',
|
||||
'schedule': crontab(hour=2, minute=0),
|
||||
'description': 'Runs daily at 02:00 UTC.',
|
||||
},
|
||||
'process-scheduled-announcements': {
|
||||
'task': 'communications.tasks.process_scheduled_announcements',
|
||||
'schedule': crontab(minute='*/15'),
|
||||
'description': 'Runs every 15 minutes to dispatch scheduled announcements.',
|
||||
},
|
||||
}
|
||||
|
||||
EMAIL_TIMEOUT_SECONDS = 10
|
||||
|
||||
CELERY_TASK_SOFT_TIME_LIMIT = 20
|
||||
CELERY_TASK_TIME_LIMIT = 30
|
||||
14
backend/config/services/location.py
Normal file
14
backend/config/services/location.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Configuration for Django location fields backed by OpenStreetMap."""
|
||||
|
||||
DEFAULT_MAP_CENTER = [37.0629098, 50.4232464]
|
||||
|
||||
LOCATION_FIELD = {
|
||||
'map.provider': 'openstreetmap',
|
||||
'map.zoom': 13,
|
||||
'map.center': DEFAULT_MAP_CENTER,
|
||||
'map.language': 'fa',
|
||||
'search.provider': 'nominatim',
|
||||
'search.url': 'https://nominatim.openstreetmap.org/search/',
|
||||
'search.params': {'format': 'json', 'addressdetails': 1},
|
||||
'search.headers': {'User-Agent': 'Django CS Association App'},
|
||||
}
|
||||
12
backend/config/services/notifications.py
Normal file
12
backend/config/services/notifications.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from decouple import config
|
||||
|
||||
# Added VAPID configuration for web push notifications
|
||||
# VAPID Configuration for Web Push Notifications
|
||||
VAPID_PUBLIC_KEY = config('VAPID_PUBLIC_KEY', default='')
|
||||
VAPID_PRIVATE_KEY = config('VAPID_PRIVATE_KEY', default='')
|
||||
VAPID_CLAIMS = {
|
||||
"sub": config('VAPID_SUBJECT', default='mailto:admin@csassociation.com')
|
||||
}
|
||||
|
||||
# Site URL for push notification links
|
||||
SITE_URL = config('SITE_URL', default='http://localhost:8000')
|
||||
94
backend/config/services/unfold.py
Normal file
94
backend/config/services/unfold.py
Normal file
@@ -0,0 +1,94 @@
|
||||
from django.conf import settings
|
||||
from django.templatetags.static import static
|
||||
|
||||
# Django Unfold Configuration
|
||||
UNFOLD = {
|
||||
"SITE_TITLE": "GuilanCE Association Admin",
|
||||
"SITE_HEADER": "GuilanCE Association",
|
||||
"SITE_URL": "/",
|
||||
"SITE_ICON": lambda request: static("img/logo.png"),
|
||||
# "SITE_LOGO": lambda request: static("img/logo.png"),
|
||||
"SITE_SYMBOL": "speed",
|
||||
"SHOW_HISTORY": True,
|
||||
"SHOW_VIEW_ON_SITE": True,
|
||||
# "SHOW_BACK_BUTTON": True,
|
||||
"ENVIRONMENT": "config.services.unfold.environment_callback",
|
||||
"LOGIN": {
|
||||
"image": lambda request: request.build_absolute_uri("/static/images/login-bg.jpg"),
|
||||
"redirect_after": lambda request: request.build_absolute_uri("/admin/"),
|
||||
},
|
||||
"STYLES": [
|
||||
lambda request: request.build_absolute_uri("/static/css/styles.css"),
|
||||
],
|
||||
"SCRIPTS": [
|
||||
lambda request: request.build_absolute_uri("/static/js/scripts.js"),
|
||||
],
|
||||
"COLORS": {
|
||||
"primary": {
|
||||
"50": "250 245 255",
|
||||
"100": "243 232 255",
|
||||
"200": "233 213 255",
|
||||
"300": "216 180 254",
|
||||
"400": "196 144 254",
|
||||
"500": "168 85 247",
|
||||
"600": "147 51 234",
|
||||
"700": "126 34 206",
|
||||
"800": "107 33 168",
|
||||
"900": "88 28 135",
|
||||
},
|
||||
},
|
||||
"EXTENSIONS": {
|
||||
"modeltranslation": {
|
||||
"flags": {
|
||||
"en": "🇺🇸",
|
||||
"fa": "🇮🇷",
|
||||
},
|
||||
},
|
||||
},
|
||||
"SIDEBAR": {
|
||||
"show_search": True,
|
||||
"show_all_applications": True,
|
||||
"navigation": [
|
||||
{
|
||||
"title": "Navigation",
|
||||
"separator": True,
|
||||
"items": [
|
||||
{
|
||||
"title": "Dashboard",
|
||||
"icon": "dashboard",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/"),
|
||||
# "badge": 3
|
||||
},
|
||||
{
|
||||
"title": "Users",
|
||||
"icon": "account_circle",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/users/user/"),
|
||||
},
|
||||
{
|
||||
"title": "Blog",
|
||||
"icon": "post",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/blog/"),
|
||||
},
|
||||
{
|
||||
"title": "Events",
|
||||
"icon": "event",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/events/"),
|
||||
},
|
||||
{
|
||||
"title": "Gallery",
|
||||
"icon": "filter",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/gallery/gallery/"),
|
||||
},
|
||||
{
|
||||
"title": "Communications",
|
||||
"icon": "call",
|
||||
"link": lambda request: request.build_absolute_uri("/admin/communications/"),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def environment_callback(request):
|
||||
return ["Development", "warning"] if settings.DEBUG else ["Production", "success"]
|
||||
10
backend/config/services/zarinpal.py
Normal file
10
backend/config/services/zarinpal.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from decouple import config
|
||||
|
||||
ZARINPAL_MERCHANT_ID = config('ZARINPAL_MERCHANT_ID', default='')
|
||||
ZARINPAL_USE_SANDBOX = config('ZARINPAL_USE_SANDBOX', default=False, cast=bool)
|
||||
|
||||
ZARINPAL_API_BASE = "https://sandbox.zarinpal.com" if ZARINPAL_USE_SANDBOX else "https://payment.zarinpal.com"
|
||||
ZARINPAL_REQUEST_URL = f"{ZARINPAL_API_BASE}/pg/v4/payment/request.json"
|
||||
ZARINPAL_VERIFY_URL = f"{ZARINPAL_API_BASE}/pg/v4/payment/verify.json"
|
||||
ZARINPAL_STARTPAY = f"{ZARINPAL_API_BASE}/pg/StartPay/"
|
||||
ZARINPAL_CALLBACK_URL = config('ZARINPAL_CALLBACK_URL', default='http://localhost:8000/api/payments/callback')
|
||||
Reference in New Issue
Block a user