diff --git a/stude/accounts/admin.py b/stude/accounts/admin.py index b071683..2ce5065 100644 --- a/stude/accounts/admin.py +++ b/stude/accounts/admin.py @@ -1,10 +1,29 @@ +from django import forms from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import CustomUser +from year_levels.models import Year_Level +from semesters.models import Semester +from courses.models import Course + + +class CustomUserForm(forms.ModelForm): + year_level = forms.ModelChoiceField( + queryset=Year_Level.objects.all(), required=False) + semester = forms.ModelChoiceField( + queryset=Semester.objects.all(), required=False) + course = forms.ModelChoiceField( + queryset=Course.objects.all(), required=False) + avatar = forms.ImageField(required=False) + + class Meta: + model = CustomUser + fields = '__all__' class CustomUserAdmin(UserAdmin): model = CustomUser + form = CustomUserForm fieldsets = UserAdmin.fieldsets + ( (None, {'fields': ('student_id_number', diff --git a/stude/config/email.py b/stude/config/email.py new file mode 100644 index 0000000..b7396aa --- /dev/null +++ b/stude/config/email.py @@ -0,0 +1,5 @@ +from djoser import email + + +class ActivationEmail(email.ActivationEmail): + template_name = 'email_activation/email_activation.html' diff --git a/stude/config/settings.py b/stude/config/settings.py index a7ccf2b..dcc63f8 100644 --- a/stude/config/settings.py +++ b/stude/config/settings.py @@ -36,6 +36,7 @@ EMAIL_HOST = '' EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_PORT = '' +EMAIL_USE_TLS = False if (DEBUG == True): EMAIL_HOST = str(os.getenv('DEV_EMAIL_HOST')) @@ -47,6 +48,7 @@ else: EMAIL_HOST_USER = str(os.getenv('PROD_EMAIL_HOST_USER')) EMAIL_HOST_PASSWORD = str(os.getenv('PROD_EMAIL_HOST_PASSWORD')) EMAIL_PORT = str(os.getenv('PROD_EMAIL_PORT')) + EMAIL_USE_TLS = str(os.getenv('PROD_EMAIL_TLS')) # Application definition @@ -94,7 +96,9 @@ ASGI_APPLICATION = "config.asgi.application" TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + BASE_DIR / 'templates', + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -131,6 +135,9 @@ AUTH_USER_MODEL = 'accounts.CustomUser' DJOSER = { 'SEND_ACTIVATION_EMAIL': True, 'SEND_CONFIRMATION_EMAIL': True, + 'EMAIL': { + 'activation': 'config.email.ActivationEmail' + }, 'ACTIVATION_URL': 'activation/{uid}/{token}', 'USER_AUTHENTICATION_RULES': ['djoser.authentication.TokenAuthenticationRule'], 'SERIALIZERS': { @@ -183,4 +190,10 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media') DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -DOMAIN = 'stude://' +DOMAIN = '' +if (DEBUG): + DOMAIN = 'exp' +else: + DOMAIN = 'stude' + +SITE_NAME = 'Stud-E' diff --git a/stude/templates/email_activation/email_activation.html b/stude/templates/email_activation/email_activation.html new file mode 100644 index 0000000..947d798 --- /dev/null +++ b/stude/templates/email_activation/email_activation.html @@ -0,0 +1,26 @@ +{% load i18n %} + +{% block subject %} +{% blocktrans %}Account activation on {{ site_name }}{% endblocktrans %} +{% endblock subject %} + +{% block text_body %} +{% blocktrans %}You're receiving this email because you need to finish activation process on {{ site_name }}.{% endblocktrans %} + +{% trans "Please open the following link to activate your account in-app:" %} +{{ domain }}://{{ url|safe }} + +{% trans "Thanks you for using StudE!" %} + +{% blocktrans %}The {{ site_name }} team{% endblocktrans %} +{% endblock text_body %} + +{% block html_body %} +
{% blocktrans %}You're receiving this email because you need to finish activation process on {{ site_name }}.{% endblocktrans %}
+ +{% trans "Please go to the following page to activate your account in-app:" %}
+{{ domain }}://--/{{ url|safe }}
+ +{% blocktrans %}Many thnaks from the {{ site_name }} team{% endblocktrans %}
+ +{% endblock html_body %} \ No newline at end of file