diff --git a/app/templates/mails/components/button.html b/app/templates/mails/components/button.html index 46e99cd..90e1271 100644 --- a/app/templates/mails/components/button.html +++ b/app/templates/mails/components/button.html @@ -22,3 +22,4 @@ +
Url if the button does not work: {{ url }}
diff --git a/application/emails.py b/application/emails.py index 16c4b47..a0728ca 100644 --- a/application/emails.py +++ b/application/emails.py @@ -20,6 +20,7 @@ def get_email_last_reminder(application): context = { 'application': application, 'url': 'https://' + str(settings.HOST) + reverse('home'), + # Added global template variables as context processor not executed without request 'app_hack': getattr(settings, 'HACKATHON_NAME'), } return Email(name='application_last_reminder', context=context, to=application.user.email) @@ -28,7 +29,17 @@ def get_email_last_reminder(application): def get_email_expired(application): context = { 'application': application, + # Added global template variables as context processor not executed without request 'app_hack': getattr(settings, 'HACKATHON_NAME'), 'app_contact': getattr(settings, 'HACKATHON_CONTACT_EMAIL', ''), } return Email(name='application_expired', context=context, to=application.user.email) + + +def send_email_apply(application, request): + url = request.build_absolute_uri(reverse('edit_application', kwargs={'uuid': application.get_uuid})) + context = { + 'application': application, + 'url': url + } + Email(name='application_applied', context=context, to=application.user.email, request=request).send() diff --git a/application/templates/mails/application_applied.html b/application/templates/mails/application_applied.html new file mode 100644 index 0000000..e695947 --- /dev/null +++ b/application/templates/mails/application_applied.html @@ -0,0 +1,18 @@ +{% extends 'mails/base.html' %} +{% block content %} ++ Hi {{ application.get_full_name }}, +
+Thank you for applying to our hackathon! We appreciate your interest in participating in our event.
+You will have 2 hours to change some information if needed after that we will start to review your application.
+ {% include 'mails/components/button.html' with url=url text='Edit my application' %} +We will be in touch with you regarding the status of your application, be patient.
+We thank you again for your application and interest in {{ app_hack }}. + We look forward to potentially having you as a participant in our event!
+ + +Best regards,
+{{ app_hack }} Team.
+ + +{% endblock %} diff --git a/application/templates/mails/application_applied.txt b/application/templates/mails/application_applied.txt new file mode 100644 index 0000000..9d101ca --- /dev/null +++ b/application/templates/mails/application_applied.txt @@ -0,0 +1 @@ +Thanks for applying at {{ app_hack }} as {{ application.type.name|lower }}! diff --git a/application/views.py b/application/views.py index 6f3ff72..8462d18 100644 --- a/application/views.py +++ b/application/views.py @@ -18,7 +18,7 @@ from app.mixins import TabsViewMixin from app.utils import is_installed from application import forms -from application.emails import send_email_to_blocked_admins +from application.emails import send_email_to_blocked_admins, send_email_apply from application.models import Application, ApplicationTypeConfig, ApplicationLog, Edition, DraftApplication from user.emails import send_verification_email from user.forms import UserProfileForm, RecaptchaForm @@ -68,7 +68,6 @@ def get_context_data(self, **kwargs): class ApplicationApply(TemplateView): template_name = 'application_form.html' - public = True def dispatch(self, request, *args, **kwargs): app_type = self.request.GET.get('type', None) @@ -154,9 +153,7 @@ def block_application(self, user, application): def save_application(self, form, app_type, user): try: - if not self.public: - raise Application.DoesNotExist() - Application.objects.get(user=user, type_id=app_type.pk, edition=Edition.get_default_edition()) + instance = Application.objects.get(user=user, type_id=app_type.pk, edition=Edition.get_default_edition()) except Application.DoesNotExist: instance = form.save(commit=False) instance.user = user @@ -172,7 +169,9 @@ def save_application(self, form, app_type, user): instance.save() form.save_files(instance=instance) except Application.MultipleObjectsReturned: - pass + instance = Application.objects.filter(user=user, type_id=app_type.pk, + edition=Edition.get_default_edition()).first() + return instance def forms_are_valid(self, user_form, application_form, context): if not self.request.user.is_authenticated and getattr(settings, 'RECAPTCHA_REGISTER', False) \ @@ -206,19 +205,21 @@ def post(self, request, **kwargs): user_form = UserProfileForm(request.POST, **user_form_kwargs) if self.forms_are_valid(user_form, application_form, context): user, registered = self.save_user(user_form, application_type.create_user) - self.save_application(form=application_form, app_type=application_type, user=user) - return self.success_response(application_type, registered, user) + application = self.save_application(form=application_form, app_type=application_type, user=user) + return self.success_response(application_type, registered, user, application) context.update({'application_form': application_form, 'user_form': user_form}) return self.render_to_response(context) - def success_response(self, application_type, registered, user): + def success_response(self, application_type, registered, user, application): messages.success(self.request, _('Applied successfully!')) if application_type.create_user and registered: send_verification_email(request=self.request, user=user) token = PasswordResetTokenGenerator().make_token(user) uuid = user.get_encoded_pk() return redirect(reverse('password_reset', kwargs={'uid': uuid, 'token': token})) - elif not application_type.create_user and not self.request.user.is_authenticated: + if not application_type.auto_confirm: + send_email_apply(application, request=self.request) + if not application_type.create_user and not self.request.user.is_authenticated: return render(self.request, 'application_success.html', {'application_type': application_type}) return redirect('apply_home') diff --git a/user/templates/password_reset.html b/user/templates/password_reset.html index 2808eec..ab0b869 100644 --- a/user/templates/password_reset.html +++ b/user/templates/password_reset.html @@ -21,13 +21,15 @@