added logger to file

remotes/origin/roistat-logger-2-gleb
Gleb Mikhaylov 6 years ago
parent d71b8f7cca
commit 15a61d500b
  1. 32
      project/settings.py
  2. 33
      project/views.py

@ -25,7 +25,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY', 'jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j')
SECRET_KEY = os.getenv(
'SECRET_KEY', 'jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', False)
@ -200,6 +201,11 @@ LOGGING = {
'level': 'WARNING',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/app/media/main.log',
},
},
'loggers': {
'django.request': {
@ -214,9 +220,13 @@ LOGGING = {
'handlers': ['console', ],
},
'': {
'handlers': ['sentry',],
'handlers': ['sentry', ],
'level': "INFO",
},
'roistat': {
'handlers': ['file'],
'level': 'DEBUG'
},
}
}
@ -258,7 +268,8 @@ SENDGRID_API_KEY = os.getenv('SENDGRID_API_KEY')
# SMS
# https://github.com/twilio/twilio-python
TWILIO_ACCOUNT = os.getenv('TWILIO_ACCOUNT', 'ACdf4a96b776cc764bc3ec0f0e136ba550')
TWILIO_ACCOUNT = os.getenv(
'TWILIO_ACCOUNT', 'ACdf4a96b776cc764bc3ec0f0e136ba550')
TWILIO_TOKEN = os.getenv('TWILIO_TOKEN', '559a6b1fce121759c9af2dcbb3f755ea')
TWILIO_FROM_PHONE = os.getenv('TWILIO_FROM_PHONE', '+37128914409')
@ -297,8 +308,10 @@ REST_FRAMEWORK = {
# Celery settings
CELERY_BROKER_URL = os.getenv('REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_BROKER_DB', '0')
CELERY_RESULT_BACKEND = os.getenv('REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_RESULTS_DB', '1')
CELERY_BROKER_URL = os.getenv(
'REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_BROKER_DB', '0')
CELERY_RESULT_BACKEND = os.getenv(
'REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_RESULTS_DB', '1')
CELERY_TASK_SERIALIZER = 'json'
CELERY_BEAT_SCHEDULE = {
@ -350,8 +363,10 @@ except ImportError:
pass
else:
Paymentwall.set_api_type(Paymentwall.API_GOODS)
Paymentwall.set_app_key(os.getenv('PAYMENTWALL_APP_KEY', 'd6f02b90cf6b16220932f4037578aff7'))
Paymentwall.set_secret_key(os.getenv('PAYMENTWALL_SECRET_KEY', '4ea515bf94e34cf28646c2e12a7b8707'))
Paymentwall.set_app_key(
os.getenv('PAYMENTWALL_APP_KEY', 'd6f02b90cf6b16220932f4037578aff7'))
Paymentwall.set_secret_key(
os.getenv('PAYMENTWALL_SECRET_KEY', '4ea515bf94e34cf28646c2e12a7b8707'))
# Mixpanel settings
MIX_TOKEN = os.getenv('MIXPANEL_TOKEN', '79bd6bfd98667ed977737e6810b8abcd')
@ -361,7 +376,8 @@ MIX_TOKEN = os.getenv('MIXPANEL_TOKEN', '79bd6bfd98667ed977737e6810b8abcd')
if DEBUG:
CORS_ORIGIN_ALLOW_ALL = True
else:
CORS_ORIGIN_WHITELIST = os.getenv('CORS_ORIGIN_WHITELIST', 'lilcity.9ev.ru:8080').split(',')
CORS_ORIGIN_WHITELIST = os.getenv(
'CORS_ORIGIN_WHITELIST', 'lilcity.9ev.ru:8080').split(',')
# Swagger doc settings

@ -31,13 +31,15 @@ class IndexView(TemplateView):
now_time = now()
try:
school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday(), is_camp=True)
school_schedule = SchoolSchedule.objects.get(
weekday=now_time.isoweekday(), is_camp=True)
except SchoolSchedule.DoesNotExist:
online = False
online_coming_soon = False
school_schedule = None
else:
end_at = datetime.combine(now_time.today(), school_schedule.start_at)
end_at = datetime.combine(
now_time.today(), school_schedule.start_at)
online = (
school_schedule.start_at <= now_time.time() and
(end_at + timedelta(hours=1)).time() >= now_time.time() and
@ -45,7 +47,8 @@ class IndexView(TemplateView):
)
online_coming_soon = (
school_schedule.start_at > now_time.time() and
datetime.combine(datetime.today(), school_schedule.start_at) - timedelta(hours=12)
datetime.combine(
datetime.today(), school_schedule.start_at) - timedelta(hours=12)
<= datetime.combine(datetime.today(), now_time.time()) and
school_schedule.current_camp_lesson
)
@ -91,14 +94,17 @@ class IndexView(TemplateView):
if user_gift_certificate:
try:
user_gift_certificate = short_url.decode_url(user_gift_certificate)
user_gift_certificate = UserGiftCertificate.objects.get(pk=user_gift_certificate, bonuses_sent__isnull=True)
user_gift_certificate = short_url.decode_url(
user_gift_certificate)
user_gift_certificate = UserGiftCertificate.objects.get(
pk=user_gift_certificate, bonuses_sent__isnull=True)
except:
user_gift_certificate = None
review_images = list(map(str, range(1, 107)))
shuffle(review_images)
teachers = User.objects.filter(role=User.TEACHER_ROLE, show_in_mainpage=True)
teachers = User.objects.filter(
role=User.TEACHER_ROLE, show_in_mainpage=True)
if teachers.count() % 2 == 0:
teachers = teachers[:teachers.count() - 1]
@ -128,6 +134,7 @@ class IndexView(TemplateView):
'is_purchased_future': False,
})
return context
@ -136,7 +143,8 @@ class SchoolSchedulesView(TemplateView):
def get_context_data(self):
context = super().get_context_data()
context['school_schedules'] = SchoolSchedule.objects.filter(is_camp=True)
context['school_schedules'] = SchoolSchedule.objects.filter(
is_camp=True)
return context
@ -163,12 +171,13 @@ class PackagesView(TemplateView):
context['last_school_payment'] = last_school_payment
if last_school_payment:
next_month = (last_school_payment.date_end + timedelta(1)).month
context['next_buy_date'] = last_school_payment.date_end + timedelta(1)
context['next_buy_date'] = last_school_payment.date_end + \
timedelta(1)
context['school_months_left'] = (school_end.month - next_month
if next_month <= school_end.month
else (school_end.month + 13) - next_month)
if next_month <= school_end.month
else (school_end.month + 13) - next_month)
else:
context['school_months_left'] = (school_end.month - today.month
if today.month <= school_end.month
else (school_end.month + 13) - today.month)
if today.month <= school_end.month
else (school_end.month + 13) - today.month)
return context

Loading…
Cancel
Save