From 07888301e615e56b575a69c607c563771e2de305 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 13:26:52 +0100 Subject: [PATCH 01/29] Initial branch commit --- .gitignore | 2 + .idea/workspace.xml | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 .idea/workspace.xml diff --git a/.gitignore b/.gitignore index a38642ff..4cfdece2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ __pycache__/ *.sqlite3 # static/ # media/ +venv/ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..62fb67b0 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1602841830341 + + + + + + + + + + + + \ No newline at end of file From 34fc3fd0514c87fc15e51d8115249bac63905f3a Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 15:10:16 +0100 Subject: [PATCH 02/29] Test commit --- .idea/ci-hackathon-app.iml | 34 +++++++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 26 ++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 4 +++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ .idea/workspace.xml | 15 +++++--- 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 .idea/ci-hackathon-app.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/ci-hackathon-app.iml b/.idea/ci-hackathon-app.iml new file mode 100644 index 00000000..db74defb --- /dev/null +++ b/.idea/ci-hackathon-app.iml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..104978b1 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,26 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..cd204b7e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..fcda16a5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 62fb67b0..07e1ff9f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,9 @@ - + + + @@ -85,9 +88,13 @@ \ No newline at end of file From 7c504ab22973027650168acc3375af445f6b28a0 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 15:16:16 +0100 Subject: [PATCH 03/29] .idea/ added to gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4cfdece2..8903c917 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ __pycache__/ # static/ # media/ venv/ - +.idea/ From d93ccf9adedf4c5ab53397b61009d93e53623e29 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 15:17:49 +0100 Subject: [PATCH 04/29] Removed incorrectly pushed Pycharm default .idea folder from repo --- .idea/ci-hackathon-app.iml | 34 ------ .idea/inspectionProfiles/Project_Default.xml | 26 ----- .../inspectionProfiles/profiles_settings.xml | 6 -- .idea/misc.xml | 4 - .idea/modules.xml | 8 -- .idea/vcs.xml | 6 -- .idea/workspace.xml | 100 ------------------ 7 files changed, 184 deletions(-) delete mode 100644 .idea/ci-hackathon-app.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/ci-hackathon-app.iml b/.idea/ci-hackathon-app.iml deleted file mode 100644 index db74defb..00000000 --- a/.idea/ci-hackathon-app.iml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 104978b1..00000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da..00000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index cd204b7e..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index fcda16a5..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 07e1ff9f..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1602841830341 - - - - - - - - - - - - - - - - \ No newline at end of file From 365720f48154202a5ff5f2bb3da30ee407f62313 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 20:35:58 +0100 Subject: [PATCH 05/29] Setup default allauth via settings.py additional allauth settings and urls in urls.py --- main/settings.py | 10 ++++++++++ main/urls.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main/settings.py b/main/settings.py index 4646cb82..74cbe646 100644 --- a/main/settings.py +++ b/main/settings.py @@ -79,6 +79,16 @@ SITE_ID = 1 +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +ACCOUNT_AUTHENTICATION_METHOD = 'username_email' +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_EMAIL_VERIFICATION = 'mandatory' +ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE = True +ACCOUNT_USERNAME_MIN_LENGTH = 4 +LOGIN_URL = '/accounts/login/' +LOGIN_REDIRECT_URL = '/' + WSGI_APPLICATION = "main.wsgi.application" diff --git a/main/urls.py b/main/urls.py index 9786d549..1cdc53fe 100644 --- a/main/urls.py +++ b/main/urls.py @@ -4,6 +4,6 @@ urlpatterns = [ path("", include("home.urls")), path("admin/", admin.site.urls), - path("accounts", include("allauth.urls")), + path("accounts/", include("allauth.urls")), path("profile/", include("profiles.urls")), ] From db72f44deed7e6bc16e04bab955707bd831cd166 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Fri, 16 Oct 2020 21:22:34 +0100 Subject: [PATCH 06/29] Copied allauth account/socialaccount/base.html template files from Lib/allauth package into root templates directory --- .../allauth/account/account_inactive.html | 11 +++ templates/allauth/account/base.html | 1 + templates/allauth/account/email.html | 73 +++++++++++++++++++ .../email/email_confirmation_message.txt | 9 +++ .../email_confirmation_signup_message.txt | 1 + .../email_confirmation_signup_subject.txt | 1 + .../email/email_confirmation_subject.txt | 4 + .../email/password_reset_key_message.txt | 12 +++ .../email/password_reset_key_subject.txt | 4 + templates/allauth/account/email_confirm.html | 31 ++++++++ templates/allauth/account/login.html | 46 ++++++++++++ templates/allauth/account/logout.html | 21 ++++++ .../messages/cannot_delete_primary_email.txt | 2 + .../messages/email_confirmation_sent.txt | 2 + .../account/messages/email_confirmed.txt | 2 + .../account/messages/email_deleted.txt | 2 + .../allauth/account/messages/logged_in.txt | 4 + .../allauth/account/messages/logged_out.txt | 2 + .../account/messages/password_changed.txt | 2 + .../allauth/account/messages/password_set.txt | 2 + .../account/messages/primary_email_set.txt | 2 + .../messages/unverified_primary_email.txt | 2 + .../allauth/account/password_change.html | 15 ++++ templates/allauth/account/password_reset.html | 24 ++++++ .../allauth/account/password_reset_done.html | 16 ++++ .../account/password_reset_from_key.html | 23 ++++++ .../account/password_reset_from_key_done.html | 9 +++ templates/allauth/account/password_set.html | 15 ++++ templates/allauth/account/signup.html | 21 ++++++ templates/allauth/account/signup_closed.html | 11 +++ .../account/snippets/already_logged_in.html | 5 ++ .../allauth/account/verification_sent.html | 12 +++ .../account/verified_email_required.html | 23 ++++++ templates/allauth/base.html | 40 ++++++++++ .../socialaccount/authentication_error.html | 11 +++ templates/allauth/socialaccount/base.html | 1 + .../allauth/socialaccount/connections.html | 54 ++++++++++++++ .../socialaccount/login_cancelled.html | 15 ++++ .../messages/account_connected.txt | 2 + .../messages/account_connected_other.txt | 2 + .../messages/account_connected_updated.txt | 1 + .../messages/account_disconnected.txt | 2 + templates/allauth/socialaccount/signup.html | 22 ++++++ .../socialaccount/snippets/login_extra.html | 3 + .../socialaccount/snippets/provider_list.html | 20 +++++ 45 files changed, 583 insertions(+) create mode 100644 templates/allauth/account/account_inactive.html create mode 100644 templates/allauth/account/base.html create mode 100644 templates/allauth/account/email.html create mode 100644 templates/allauth/account/email/email_confirmation_message.txt create mode 100644 templates/allauth/account/email/email_confirmation_signup_message.txt create mode 100644 templates/allauth/account/email/email_confirmation_signup_subject.txt create mode 100644 templates/allauth/account/email/email_confirmation_subject.txt create mode 100644 templates/allauth/account/email/password_reset_key_message.txt create mode 100644 templates/allauth/account/email/password_reset_key_subject.txt create mode 100644 templates/allauth/account/email_confirm.html create mode 100644 templates/allauth/account/login.html create mode 100644 templates/allauth/account/logout.html create mode 100644 templates/allauth/account/messages/cannot_delete_primary_email.txt create mode 100644 templates/allauth/account/messages/email_confirmation_sent.txt create mode 100644 templates/allauth/account/messages/email_confirmed.txt create mode 100644 templates/allauth/account/messages/email_deleted.txt create mode 100644 templates/allauth/account/messages/logged_in.txt create mode 100644 templates/allauth/account/messages/logged_out.txt create mode 100644 templates/allauth/account/messages/password_changed.txt create mode 100644 templates/allauth/account/messages/password_set.txt create mode 100644 templates/allauth/account/messages/primary_email_set.txt create mode 100644 templates/allauth/account/messages/unverified_primary_email.txt create mode 100644 templates/allauth/account/password_change.html create mode 100644 templates/allauth/account/password_reset.html create mode 100644 templates/allauth/account/password_reset_done.html create mode 100644 templates/allauth/account/password_reset_from_key.html create mode 100644 templates/allauth/account/password_reset_from_key_done.html create mode 100644 templates/allauth/account/password_set.html create mode 100644 templates/allauth/account/signup.html create mode 100644 templates/allauth/account/signup_closed.html create mode 100644 templates/allauth/account/snippets/already_logged_in.html create mode 100644 templates/allauth/account/verification_sent.html create mode 100644 templates/allauth/account/verified_email_required.html create mode 100644 templates/allauth/base.html create mode 100644 templates/allauth/socialaccount/authentication_error.html create mode 100644 templates/allauth/socialaccount/base.html create mode 100644 templates/allauth/socialaccount/connections.html create mode 100644 templates/allauth/socialaccount/login_cancelled.html create mode 100644 templates/allauth/socialaccount/messages/account_connected.txt create mode 100644 templates/allauth/socialaccount/messages/account_connected_other.txt create mode 100644 templates/allauth/socialaccount/messages/account_connected_updated.txt create mode 100644 templates/allauth/socialaccount/messages/account_disconnected.txt create mode 100644 templates/allauth/socialaccount/signup.html create mode 100644 templates/allauth/socialaccount/snippets/login_extra.html create mode 100644 templates/allauth/socialaccount/snippets/provider_list.html diff --git a/templates/allauth/account/account_inactive.html b/templates/allauth/account/account_inactive.html new file mode 100644 index 00000000..3347f4fd --- /dev/null +++ b/templates/allauth/account/account_inactive.html @@ -0,0 +1,11 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Account Inactive" %}{% endblock %} + +{% block content %} +

{% trans "Account Inactive" %}

+ +

{% trans "This account is inactive." %}

+{% endblock %} diff --git a/templates/allauth/account/base.html b/templates/allauth/account/base.html new file mode 100644 index 00000000..94d9808c --- /dev/null +++ b/templates/allauth/account/base.html @@ -0,0 +1 @@ +{% extends "base.html" %} diff --git a/templates/allauth/account/email.html b/templates/allauth/account/email.html new file mode 100644 index 00000000..9a9ed1f8 --- /dev/null +++ b/templates/allauth/account/email.html @@ -0,0 +1,73 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "E-mail Addresses" %}{% endblock %} + +{% block content %} +

{% trans "E-mail Addresses" %}

+{% if user.emailaddress_set.all %} +

{% trans 'The following e-mail addresses are associated with your account:' %}

+ + + +{% else %} +

{% trans 'Warning:'%} {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}

+ +{% endif %} + + +

{% trans "Add E-mail Address" %}

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+ +{% endblock %} + + +{% block extra_body %} + +{% endblock %} diff --git a/templates/allauth/account/email/email_confirmation_message.txt b/templates/allauth/account/email/email_confirmation_message.txt new file mode 100644 index 00000000..2d856f76 --- /dev/null +++ b/templates/allauth/account/email/email_confirmation_message.txt @@ -0,0 +1,9 @@ +{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}! + +You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account. + +To confirm this is correct, go to {{ activate_url }} +{% endblocktrans %} +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }}! +{{ site_domain }}{% endblocktrans %} +{% endautoescape %} diff --git a/templates/allauth/account/email/email_confirmation_signup_message.txt b/templates/allauth/account/email/email_confirmation_signup_message.txt new file mode 100644 index 00000000..9996f7e5 --- /dev/null +++ b/templates/allauth/account/email/email_confirmation_signup_message.txt @@ -0,0 +1 @@ +{% include "account/email/email_confirmation_message.txt" %} diff --git a/templates/allauth/account/email/email_confirmation_signup_subject.txt b/templates/allauth/account/email/email_confirmation_signup_subject.txt new file mode 100644 index 00000000..4c85ebb9 --- /dev/null +++ b/templates/allauth/account/email/email_confirmation_signup_subject.txt @@ -0,0 +1 @@ +{% include "account/email/email_confirmation_subject.txt" %} diff --git a/templates/allauth/account/email/email_confirmation_subject.txt b/templates/allauth/account/email/email_confirmation_subject.txt new file mode 100644 index 00000000..b0a876f5 --- /dev/null +++ b/templates/allauth/account/email/email_confirmation_subject.txt @@ -0,0 +1,4 @@ +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Please Confirm Your E-mail Address{% endblocktrans %} +{% endautoescape %} diff --git a/templates/allauth/account/email/password_reset_key_message.txt b/templates/allauth/account/email/password_reset_key_message.txt new file mode 100644 index 00000000..d74dfa82 --- /dev/null +++ b/templates/allauth/account/email/password_reset_key_message.txt @@ -0,0 +1,12 @@ +{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}! + +You're receiving this e-mail because you or someone else has requested a password for your user account. +It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %} + +{{ password_reset_url }} + +{% if username %}{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %} + +{% endif %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}! +{{ site_domain }}{% endblocktrans %} +{% endautoescape %} diff --git a/templates/allauth/account/email/password_reset_key_subject.txt b/templates/allauth/account/email/password_reset_key_subject.txt new file mode 100644 index 00000000..6840c40b --- /dev/null +++ b/templates/allauth/account/email/password_reset_key_subject.txt @@ -0,0 +1,4 @@ +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Password Reset E-mail{% endblocktrans %} +{% endautoescape %} diff --git a/templates/allauth/account/email_confirm.html b/templates/allauth/account/email_confirm.html new file mode 100644 index 00000000..ac0891b5 --- /dev/null +++ b/templates/allauth/account/email_confirm.html @@ -0,0 +1,31 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% load account %} + +{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} + + +{% block content %} +

{% trans "Confirm E-mail Address" %}

+ +{% if confirmation %} + +{% user_display confirmation.email_address.user as user_display %} + +

{% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}

+ +
+{% csrf_token %} + +
+ +{% else %} + +{% url 'account_email' as email_url %} + +

{% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request.{% endblocktrans %}

+ +{% endif %} + +{% endblock %} diff --git a/templates/allauth/account/login.html b/templates/allauth/account/login.html new file mode 100644 index 00000000..17bc3a6a --- /dev/null +++ b/templates/allauth/account/login.html @@ -0,0 +1,46 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% load account socialaccount %} + +{% block head_title %}{% trans "Sign In" %}{% endblock %} + +{% block content %} + +

{% trans "Sign In" %}

+ +{% get_providers as socialaccount_providers %} + +{% if socialaccount_providers %} +

{% blocktrans with site.name as site_name %}Please sign in with one +of your existing third party accounts. Or, sign up +for a {{ site_name }} account and sign in below:{% endblocktrans %}

+ +
+ +
    + {% include "socialaccount/snippets/provider_list.html" with process="login" %} +
+ + + +
+ +{% include "socialaccount/snippets/login_extra.html" %} + +{% else %} +

{% blocktrans %}If you have not created an account yet, then please +sign up first.{% endblocktrans %}

+{% endif %} + + + +{% endblock %} diff --git a/templates/allauth/account/logout.html b/templates/allauth/account/logout.html new file mode 100644 index 00000000..2549a901 --- /dev/null +++ b/templates/allauth/account/logout.html @@ -0,0 +1,21 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Sign Out" %}{% endblock %} + +{% block content %} +

{% trans "Sign Out" %}

+ +

{% trans 'Are you sure you want to sign out?' %}

+ +
+ {% csrf_token %} + {% if redirect_field_value %} + + {% endif %} + +
+ + +{% endblock %} diff --git a/templates/allauth/account/messages/cannot_delete_primary_email.txt b/templates/allauth/account/messages/cannot_delete_primary_email.txt new file mode 100644 index 00000000..de555712 --- /dev/null +++ b/templates/allauth/account/messages/cannot_delete_primary_email.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}You cannot remove your primary e-mail address ({{email}}).{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_confirmation_sent.txt b/templates/allauth/account/messages/email_confirmation_sent.txt new file mode 100644 index 00000000..7a526f8b --- /dev/null +++ b/templates/allauth/account/messages/email_confirmation_sent.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Confirmation e-mail sent to {{email}}.{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_confirmed.txt b/templates/allauth/account/messages/email_confirmed.txt new file mode 100644 index 00000000..3427a4d8 --- /dev/null +++ b/templates/allauth/account/messages/email_confirmed.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}You have confirmed {{email}}.{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_deleted.txt b/templates/allauth/account/messages/email_deleted.txt new file mode 100644 index 00000000..5cf7cf91 --- /dev/null +++ b/templates/allauth/account/messages/email_deleted.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Removed e-mail address {{email}}.{% endblocktrans %} diff --git a/templates/allauth/account/messages/logged_in.txt b/templates/allauth/account/messages/logged_in.txt new file mode 100644 index 00000000..f49248a7 --- /dev/null +++ b/templates/allauth/account/messages/logged_in.txt @@ -0,0 +1,4 @@ +{% load account %} +{% load i18n %} +{% user_display user as name %} +{% blocktrans %}Successfully signed in as {{name}}.{% endblocktrans %} diff --git a/templates/allauth/account/messages/logged_out.txt b/templates/allauth/account/messages/logged_out.txt new file mode 100644 index 00000000..2cd4627d --- /dev/null +++ b/templates/allauth/account/messages/logged_out.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}You have signed out.{% endblocktrans %} diff --git a/templates/allauth/account/messages/password_changed.txt b/templates/allauth/account/messages/password_changed.txt new file mode 100644 index 00000000..bd5801c4 --- /dev/null +++ b/templates/allauth/account/messages/password_changed.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Password successfully changed.{% endblocktrans %} diff --git a/templates/allauth/account/messages/password_set.txt b/templates/allauth/account/messages/password_set.txt new file mode 100644 index 00000000..9d224ee0 --- /dev/null +++ b/templates/allauth/account/messages/password_set.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Password successfully set.{% endblocktrans %} diff --git a/templates/allauth/account/messages/primary_email_set.txt b/templates/allauth/account/messages/primary_email_set.txt new file mode 100644 index 00000000..b6a70dd6 --- /dev/null +++ b/templates/allauth/account/messages/primary_email_set.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Primary e-mail address set.{% endblocktrans %} diff --git a/templates/allauth/account/messages/unverified_primary_email.txt b/templates/allauth/account/messages/unverified_primary_email.txt new file mode 100644 index 00000000..9c9d0d87 --- /dev/null +++ b/templates/allauth/account/messages/unverified_primary_email.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}Your primary e-mail address must be verified.{% endblocktrans %} diff --git a/templates/allauth/account/password_change.html b/templates/allauth/account/password_change.html new file mode 100644 index 00000000..b5365791 --- /dev/null +++ b/templates/allauth/account/password_change.html @@ -0,0 +1,15 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Change Password" %}{% endblock %} + +{% block content %} +

{% trans "Change Password" %}

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/templates/allauth/account/password_reset.html b/templates/allauth/account/password_reset.html new file mode 100644 index 00000000..de23d9eb --- /dev/null +++ b/templates/allauth/account/password_reset.html @@ -0,0 +1,24 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% load account %} + +{% block head_title %}{% trans "Password Reset" %}{% endblock %} + +{% block content %} + +

{% trans "Password Reset" %}

+ {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} + +

{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+ +

{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}

+{% endblock %} diff --git a/templates/allauth/account/password_reset_done.html b/templates/allauth/account/password_reset_done.html new file mode 100644 index 00000000..e90504f7 --- /dev/null +++ b/templates/allauth/account/password_reset_done.html @@ -0,0 +1,16 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% load account %} + +{% block head_title %}{% trans "Password Reset" %}{% endblock %} + +{% block content %} +

{% trans "Password Reset" %}

+ + {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} + +

{% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

+{% endblock %} diff --git a/templates/allauth/account/password_reset_from_key.html b/templates/allauth/account/password_reset_from_key.html new file mode 100644 index 00000000..16f27e9c --- /dev/null +++ b/templates/allauth/account/password_reset_from_key.html @@ -0,0 +1,23 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% block head_title %}{% trans "Change Password" %}{% endblock %} + +{% block content %} +

{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}

+ + {% if token_fail %} + {% url 'account_reset_password' as passwd_reset_url %} +

{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

+ {% else %} + {% if form %} +
+ {% csrf_token %} + {{ form.as_p }} + +
+ {% else %} +

{% trans 'Your password is now changed.' %}

+ {% endif %} + {% endif %} +{% endblock %} diff --git a/templates/allauth/account/password_reset_from_key_done.html b/templates/allauth/account/password_reset_from_key_done.html new file mode 100644 index 00000000..85641c2e --- /dev/null +++ b/templates/allauth/account/password_reset_from_key_done.html @@ -0,0 +1,9 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% block head_title %}{% trans "Change Password" %}{% endblock %} + +{% block content %} +

{% trans "Change Password" %}

+

{% trans 'Your password is now changed.' %}

+{% endblock %} diff --git a/templates/allauth/account/password_set.html b/templates/allauth/account/password_set.html new file mode 100644 index 00000000..f5615720 --- /dev/null +++ b/templates/allauth/account/password_set.html @@ -0,0 +1,15 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Set Password" %}{% endblock %} + +{% block content %} +

{% trans "Set Password" %}

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/templates/allauth/account/signup.html b/templates/allauth/account/signup.html new file mode 100644 index 00000000..8b53b442 --- /dev/null +++ b/templates/allauth/account/signup.html @@ -0,0 +1,21 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Signup" %}{% endblock %} + +{% block content %} +

{% trans "Sign Up" %}

+ +

{% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

+ + + +{% endblock %} diff --git a/templates/allauth/account/signup_closed.html b/templates/allauth/account/signup_closed.html new file mode 100644 index 00000000..bc839506 --- /dev/null +++ b/templates/allauth/account/signup_closed.html @@ -0,0 +1,11 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Sign Up Closed" %}{% endblock %} + +{% block content %} +

{% trans "Sign Up Closed" %}

+ +

{% trans "We are sorry, but the sign up is currently closed." %}

+{% endblock %} diff --git a/templates/allauth/account/snippets/already_logged_in.html b/templates/allauth/account/snippets/already_logged_in.html new file mode 100644 index 00000000..00799f00 --- /dev/null +++ b/templates/allauth/account/snippets/already_logged_in.html @@ -0,0 +1,5 @@ +{% load i18n %} +{% load account %} + +{% user_display user as user_display %} +

{% trans "Note" %}: {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %}

diff --git a/templates/allauth/account/verification_sent.html b/templates/allauth/account/verification_sent.html new file mode 100644 index 00000000..5f713319 --- /dev/null +++ b/templates/allauth/account/verification_sent.html @@ -0,0 +1,12 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} + +{% block content %} +

{% trans "Verify Your E-mail Address" %}

+ +

{% blocktrans %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

+ +{% endblock %} diff --git a/templates/allauth/account/verified_email_required.html b/templates/allauth/account/verified_email_required.html new file mode 100644 index 00000000..8115c489 --- /dev/null +++ b/templates/allauth/account/verified_email_required.html @@ -0,0 +1,23 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} + +{% block content %} +

{% trans "Verify Your E-mail Address" %}

+ +{% url 'account_email' as email_url %} + +

{% blocktrans %}This part of the site requires us to verify that +you are who you claim to be. For this purpose, we require that you +verify ownership of your e-mail address. {% endblocktrans %}

+ +

{% blocktrans %}We have sent an e-mail to you for +verification. Please click on the link inside this e-mail. Please +contact us if you do not receive it within a few minutes.{% endblocktrans %}

+ +

{% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}

+ + +{% endblock %} diff --git a/templates/allauth/base.html b/templates/allauth/base.html new file mode 100644 index 00000000..4e125162 --- /dev/null +++ b/templates/allauth/base.html @@ -0,0 +1,40 @@ + + + + {% block head_title %}{% endblock %} + {% block extra_head %} + {% endblock %} + + + {% block body %} + + {% if messages %} +
+ Messages: +
    + {% for message in messages %} +
  • {{message}}
  • + {% endfor %} +
+
+ {% endif %} + +
+ Menu: + +
+ {% block content %} + {% endblock %} + {% endblock %} + {% block extra_body %} + {% endblock %} + + diff --git a/templates/allauth/socialaccount/authentication_error.html b/templates/allauth/socialaccount/authentication_error.html new file mode 100644 index 00000000..03002955 --- /dev/null +++ b/templates/allauth/socialaccount/authentication_error.html @@ -0,0 +1,11 @@ +{% extends "socialaccount/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Social Network Login Failure" %}{% endblock %} + +{% block content %} +

{% trans "Social Network Login Failure" %}

+ +

{% trans "An error occurred while attempting to login via your social network account." %}

+{% endblock %} diff --git a/templates/allauth/socialaccount/base.html b/templates/allauth/socialaccount/base.html new file mode 100644 index 00000000..b64fd563 --- /dev/null +++ b/templates/allauth/socialaccount/base.html @@ -0,0 +1 @@ +{% extends "account/base.html" %} diff --git a/templates/allauth/socialaccount/connections.html b/templates/allauth/socialaccount/connections.html new file mode 100644 index 00000000..f7c2729f --- /dev/null +++ b/templates/allauth/socialaccount/connections.html @@ -0,0 +1,54 @@ +{% extends "socialaccount/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Account Connections" %}{% endblock %} + +{% block content %} +

{% trans "Account Connections" %}

+ +{% if form.accounts %} +

{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}

+ + +
+{% csrf_token %} + +
+{% if form.non_field_errors %} +
{{ form.non_field_errors }}
+{% endif %} + +{% for base_account in form.accounts %} +{% with base_account.get_provider_account as account %} +
+ +
+{% endwith %} +{% endfor %} + +
+ +
+ +
+ +
+ +{% else %} +

{% trans 'You currently have no social network accounts connected to this account.' %}

+{% endif %} + +

{% trans 'Add a 3rd Party Account' %}

+ +
    +{% include "socialaccount/snippets/provider_list.html" with process="connect" %} +
+ +{% include "socialaccount/snippets/login_extra.html" %} + +{% endblock %} diff --git a/templates/allauth/socialaccount/login_cancelled.html b/templates/allauth/socialaccount/login_cancelled.html new file mode 100644 index 00000000..8d767865 --- /dev/null +++ b/templates/allauth/socialaccount/login_cancelled.html @@ -0,0 +1,15 @@ +{% extends "socialaccount/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Login Cancelled" %}{% endblock %} + +{% block content %} + +

{% trans "Login Cancelled" %}

+ +{% url 'account_login' as login_url %} + +

{% blocktrans %}You decided to cancel logging in to our site using one of your existing accounts. If this was a mistake, please proceed to sign in.{% endblocktrans %}

+ +{% endblock %} diff --git a/templates/allauth/socialaccount/messages/account_connected.txt b/templates/allauth/socialaccount/messages/account_connected.txt new file mode 100644 index 00000000..be6aa60f --- /dev/null +++ b/templates/allauth/socialaccount/messages/account_connected.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account has been connected.{% endblocktrans %} diff --git a/templates/allauth/socialaccount/messages/account_connected_other.txt b/templates/allauth/socialaccount/messages/account_connected_other.txt new file mode 100644 index 00000000..e90f6ccc --- /dev/null +++ b/templates/allauth/socialaccount/messages/account_connected_other.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account is already connected to a different account.{% endblocktrans %} diff --git a/templates/allauth/socialaccount/messages/account_connected_updated.txt b/templates/allauth/socialaccount/messages/account_connected_updated.txt new file mode 100644 index 00000000..3f7174e8 --- /dev/null +++ b/templates/allauth/socialaccount/messages/account_connected_updated.txt @@ -0,0 +1 @@ +{% extends "socialaccount/messages/account_connected.txt" %} diff --git a/templates/allauth/socialaccount/messages/account_disconnected.txt b/templates/allauth/socialaccount/messages/account_disconnected.txt new file mode 100644 index 00000000..fd43f30e --- /dev/null +++ b/templates/allauth/socialaccount/messages/account_disconnected.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account has been disconnected.{% endblocktrans %} diff --git a/templates/allauth/socialaccount/signup.html b/templates/allauth/socialaccount/signup.html new file mode 100644 index 00000000..caa2de2e --- /dev/null +++ b/templates/allauth/socialaccount/signup.html @@ -0,0 +1,22 @@ +{% extends "socialaccount/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Signup" %}{% endblock %} + +{% block content %} +

{% trans "Sign Up" %}

+ +

{% blocktrans with provider_name=account.get_provider.name site_name=site.name %}You are about to use your {{provider_name}} account to login to +{{site_name}}. As a final step, please complete the following form:{% endblocktrans %}

+ + + +{% endblock %} diff --git a/templates/allauth/socialaccount/snippets/login_extra.html b/templates/allauth/socialaccount/snippets/login_extra.html new file mode 100644 index 00000000..307def40 --- /dev/null +++ b/templates/allauth/socialaccount/snippets/login_extra.html @@ -0,0 +1,3 @@ +{% load socialaccount %} + +{% providers_media_js %} diff --git a/templates/allauth/socialaccount/snippets/provider_list.html b/templates/allauth/socialaccount/snippets/provider_list.html new file mode 100644 index 00000000..e76a2969 --- /dev/null +++ b/templates/allauth/socialaccount/snippets/provider_list.html @@ -0,0 +1,20 @@ +{% load socialaccount %} + +{% get_providers as socialaccount_providers %} + +{% for provider in socialaccount_providers %} +{% if provider.id == "openid" %} +{% for brand in provider.get_brands %} +
  • + {{brand.name}} +
  • +{% endfor %} +{% endif %} +
  • + {{provider.name}} +
  • +{% endfor %} From d3d6df3ba6a1627852055685da2d77a013b80c79 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sat, 17 Oct 2020 19:41:44 +0100 Subject: [PATCH 07/29] Default signup Allauth form extended with required fields as per user story --- accounts/__init__.py | 0 accounts/admin.py | 3 ++ accounts/apps.py | 5 ++ accounts/forms.py | 50 +++++++++++++++++++ accounts/migrations/0001_initial.py | 47 +++++++++++++++++ .../migrations/0002_auto_20201017_1918.py | 23 +++++++++ accounts/migrations/__init__.py | 0 accounts/models.py | 3 ++ accounts/tests.py | 3 ++ accounts/views.py | 3 ++ main/settings.py | 2 + 11 files changed, 139 insertions(+) create mode 100644 accounts/__init__.py create mode 100644 accounts/admin.py create mode 100644 accounts/apps.py create mode 100644 accounts/forms.py create mode 100644 accounts/migrations/0001_initial.py create mode 100644 accounts/migrations/0002_auto_20201017_1918.py create mode 100644 accounts/migrations/__init__.py create mode 100644 accounts/models.py create mode 100644 accounts/tests.py create mode 100644 accounts/views.py diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/accounts/apps.py b/accounts/apps.py new file mode 100644 index 00000000..9b3fc5a4 --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + name = 'accounts' diff --git a/accounts/forms.py b/accounts/forms.py new file mode 100644 index 00000000..f62f26fe --- /dev/null +++ b/accounts/forms.py @@ -0,0 +1,50 @@ +from allauth.account.forms import SignupForm +from django import forms + +"""List of user types to be passed into dropdown of same name for each +user selection.""" +user_types = [ + ('', 'Select Post Category'), + ('participant', 'Participant'), + ('staff', 'Staff'), + ('admin', 'Admin'), +] + +"""List of CI LMS modules to be passed into dropdown of same name for each +user selection.""" +lms_modules = [ + ('', 'Select Learning Stage'), + ('programme preliminaries', 'Programme Preliminaries'), + ('programming paradigms', 'Programming Paradigms'), + ('html fundamentals', 'HTML Fundamentals'), + ('css fundamentals', 'CSS Fundamentals'), + ('user centric frontend development', 'User Centric Frontend Development'), + ('javascript fundamentals', 'Javascript Fundamentals'), + ('interactive frontend development', 'Interactive Frontend Development'), + ('python fundamentals', 'Python Fundamentals'), + ('practical python', 'Practical Python'), + ('data centric development', 'Data Centric Development'), + ('full stack frameworks with django', 'Full Stack Frameworks with Django'), + ('alumni', 'Alumni'), + ('staff', 'Staff'), +] + + +class ExtendedSignupForm(SignupForm): + first_name = forms.CharField(max_length=20) + last_name = forms.CharField(max_length=20) + slack_display_name = forms.CharField(max_length=25) + user_type = forms.ChoiceField( + choices=user_types + ) + current_lms_module = forms.ChoiceField( + choices=lms_modules + ) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def custom_signup(self, request, user): + user.user_type=self.cleaned_data["user_type"] + user.current_lms_module=self.cleaned_data["current_lms_module"] + user.save() diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py new file mode 100644 index 00000000..6d9a8c69 --- /dev/null +++ b/accounts/migrations/0001_initial.py @@ -0,0 +1,47 @@ +# Generated by Django 3.1.1 on 2020-10-17 16:49 + +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='CustomUser', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('slack_display_name', models.CharField(max_length=50)), + ('current_lms_module', models.CharField(choices=[('', 'Select Learning Stage'), ('programme preliminaries', 'Programme Preliminaries'), ('programming paradigms', 'Programming Paradigms'), ('html fundamentals', 'HTML Fundamentals'), ('css fundamentals', 'CSS Fundamentals'), ('user centric frontend development', 'User Centric Frontend Development'), ('javascript fundamentals', 'Javascript Fundamentals'), ('interactive frontend development', 'Interactive Frontend Development'), ('python fundamentals', 'Python Fundamentals'), ('practical python', 'Practical Python'), ('data centric development', 'Data Centric Development'), ('full stack frameworks with django', 'Full Stack Frameworks with Django'), ('alumni', 'Alumni'), ('staff', 'Staff')], max_length=33)), + ('user_type', models.CharField(choices=[('', 'Select Post Category'), ('participant', 'Participant'), ('staff', 'Staff'), ('admin', 'Admin')], max_length=11)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/accounts/migrations/0002_auto_20201017_1918.py b/accounts/migrations/0002_auto_20201017_1918.py new file mode 100644 index 00000000..991a0623 --- /dev/null +++ b/accounts/migrations/0002_auto_20201017_1918.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.1 on 2020-10-17 18:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='customuser', + name='first_name', + field=models.CharField(max_length=20), + ), + migrations.AlterField( + model_name='customuser', + name='last_name', + field=models.CharField(max_length=20), + ), + ] diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 00000000..d49766e4 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. \ No newline at end of file diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/main/settings.py b/main/settings.py index 74cbe646..610835e9 100644 --- a/main/settings.py +++ b/main/settings.py @@ -27,6 +27,7 @@ "allauth.account", "allauth.socialaccount", "home", + 'accounts', "profiles", "crispy_forms", ] @@ -81,6 +82,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +ACCOUNT_FORMS = {'signup': 'accounts.forms.ExtendedSignupForm'} ACCOUNT_AUTHENTICATION_METHOD = 'username_email' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' From cccd55444bf3f93a1041182d7a7e90c6679fbee7 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sat, 17 Oct 2020 22:20:59 +0100 Subject: [PATCH 08/29] Added ommitted spacing around `=` operator in accounts/forms.py file --- accounts/forms.py | 4 +- accounts/migrations/0001_initial.py | 47 ------------------- .../migrations/0002_auto_20201017_1918.py | 23 --------- accounts/models.py | 2 +- 4 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 accounts/migrations/0001_initial.py delete mode 100644 accounts/migrations/0002_auto_20201017_1918.py diff --git a/accounts/forms.py b/accounts/forms.py index f62f26fe..725f9647 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -45,6 +45,6 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def custom_signup(self, request, user): - user.user_type=self.cleaned_data["user_type"] - user.current_lms_module=self.cleaned_data["current_lms_module"] + user.user_type = self.cleaned_data["user_type"] + user.current_lms_module = self.cleaned_data["current_lms_module"] user.save() diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py deleted file mode 100644 index 6d9a8c69..00000000 --- a/accounts/migrations/0001_initial.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-17 16:49 - -import django.contrib.auth.models -import django.contrib.auth.validators -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), - ] - - operations = [ - migrations.CreateModel( - name='CustomUser', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), - ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), - ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), - ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('slack_display_name', models.CharField(max_length=50)), - ('current_lms_module', models.CharField(choices=[('', 'Select Learning Stage'), ('programme preliminaries', 'Programme Preliminaries'), ('programming paradigms', 'Programming Paradigms'), ('html fundamentals', 'HTML Fundamentals'), ('css fundamentals', 'CSS Fundamentals'), ('user centric frontend development', 'User Centric Frontend Development'), ('javascript fundamentals', 'Javascript Fundamentals'), ('interactive frontend development', 'Interactive Frontend Development'), ('python fundamentals', 'Python Fundamentals'), ('practical python', 'Practical Python'), ('data centric development', 'Data Centric Development'), ('full stack frameworks with django', 'Full Stack Frameworks with Django'), ('alumni', 'Alumni'), ('staff', 'Staff')], max_length=33)), - ('user_type', models.CharField(choices=[('', 'Select Post Category'), ('participant', 'Participant'), ('staff', 'Staff'), ('admin', 'Admin')], max_length=11)), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), - ], - options={ - 'verbose_name': 'user', - 'verbose_name_plural': 'users', - 'abstract': False, - }, - managers=[ - ('objects', django.contrib.auth.models.UserManager()), - ], - ), - ] diff --git a/accounts/migrations/0002_auto_20201017_1918.py b/accounts/migrations/0002_auto_20201017_1918.py deleted file mode 100644 index 991a0623..00000000 --- a/accounts/migrations/0002_auto_20201017_1918.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-17 18:18 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('accounts', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='first_name', - field=models.CharField(max_length=20), - ), - migrations.AlterField( - model_name='customuser', - name='last_name', - field=models.CharField(max_length=20), - ), - ] diff --git a/accounts/models.py b/accounts/models.py index d49766e4..71a83623 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,3 +1,3 @@ from django.db import models -# Create your models here. \ No newline at end of file +# Create your models here. From 65d590b7ebfff3ba3f5d789c25c348751ba1c7fd Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sat, 17 Oct 2020 23:59:39 +0100 Subject: [PATCH 09/29] User signup is_active permission set to False using user_signed_up signal as proof of concept --- accounts/forms.py | 3 +++ accounts/models.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/accounts/forms.py b/accounts/forms.py index 725f9647..c3647d7e 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -45,6 +45,9 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def custom_signup(self, request, user): + user.first_name = self.cleaned_data["first_name"] + user.last_name = self.cleaned_data["last_name"] + user.slack_display_name = self.cleaned_data["slack_display_name"] user.user_type = self.cleaned_data["user_type"] user.current_lms_module = self.cleaned_data["current_lms_module"] user.save() diff --git a/accounts/models.py b/accounts/models.py index 71a83623..d92c0d6e 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,3 +1,10 @@ -from django.db import models +from allauth.account.signals import user_signed_up +from django.dispatch import receiver +from django.contrib.auth.models import User +from .forms import ExtendedSignupForm -# Create your models here. + +@receiver(user_signed_up) +def user_signed_up(request, user, **kwargs): + user.is_active = False + user.save() From 9061b397f9dd6b773588717ebbe5eac74c7499a0 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sun, 18 Oct 2020 12:05:14 +0100 Subject: [PATCH 10/29] Fixed merge conflicts, removed conflict markers and updated gitignore --- .gitignore | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 90ed273d..33d8a4e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,3 @@ -<<<<<<< HEAD -.env -env.py -.vscode -*.py[cod] -__pycache__/ -*.sqlite3 -# static/ -# media/ -venv/ -======= .env env.py .vscode @@ -20,4 +9,5 @@ __pycache__/ settings.json .gitpod.yml .venv/ ->>>>>>> a59f43f5987495729c6558cecb9499d22a81e13e +venv/ +.idea/ From 87cbfb9c91eb80777e2e2936c331c8081db7f1d0 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sun, 18 Oct 2020 16:49:47 +0100 Subject: [PATCH 11/29] Checked form data using request object in forms.py with if..elif..else checks per explicit user type --- accounts/models.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/accounts/models.py b/accounts/models.py index d92c0d6e..7e7941aa 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,10 +1,22 @@ from allauth.account.signals import user_signed_up from django.dispatch import receiver from django.contrib.auth.models import User -from .forms import ExtendedSignupForm @receiver(user_signed_up) def user_signed_up(request, user, **kwargs): - user.is_active = False + # capture server request object in dict for easy accessing of headers within + form = dict(request.POST) + print(form) + # check user_type value for explicit statement and set user active + # permission to true/false + if form['user_type'][0] == 'participant': + user.is_active = True + elif form['user_type'][0] == 'staff': + user.is_active = False + user.is_staff = True + else: + user.is_active = False + user.is_staff = True + user.is_superuser = True user.save() From 640655df2f9c57add3bfece0ad1c1c345da5e5a0 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sun, 18 Oct 2020 21:37:06 +0100 Subject: [PATCH 12/29] Set autofocus from username to email field in forms.py for signup template --- accounts/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accounts/forms.py b/accounts/forms.py index c3647d7e..9b039976 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -43,6 +43,8 @@ class ExtendedSignupForm(SignupForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + self.fields['email'].widget.attrs['autofocus'] = True + self.fields['username'].widget.attrs['autofocus'] = False def custom_signup(self, request, user): user.first_name = self.cleaned_data["first_name"] From 0d7e90cf8966f4b8dc249488615676e65aceef98 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Sun, 18 Oct 2020 23:52:31 +0100 Subject: [PATCH 13/29] Up-to-date migrations pushed through --- hackathon/migrations/0001_initial.py | 77 ++++++++++++++++++- .../migrations/0002_auto_20201015_1936.py | 33 -------- .../migrations/0003_auto_20201015_2020.py | 47 ----------- .../migrations/0004_auto_20201015_2224.py | 65 ---------------- .../migrations/0005_auto_20201016_1951.py | 76 ------------------ .../migrations/0006_auto_20201016_2050.py | 18 ----- .../migrations/0007_auto_20201017_1148.py | 41 ---------- 7 files changed, 73 insertions(+), 284 deletions(-) delete mode 100644 hackathon/migrations/0002_auto_20201015_1936.py delete mode 100644 hackathon/migrations/0003_auto_20201015_2020.py delete mode 100644 hackathon/migrations/0004_auto_20201015_2224.py delete mode 100644 hackathon/migrations/0005_auto_20201016_1951.py delete mode 100644 hackathon/migrations/0006_auto_20201016_2050.py delete mode 100644 hackathon/migrations/0007_auto_20201017_1148.py diff --git a/hackathon/migrations/0001_initial.py b/hackathon/migrations/0001_initial.py index 117b5d58..27be0f0f 100644 --- a/hackathon/migrations/0001_initial.py +++ b/hackathon/migrations/0001_initial.py @@ -1,9 +1,8 @@ -# Generated by Django 3.1.1 on 2020-10-15 19:02 +# Generated by Django 3.1.1 on 2020-10-18 20:58 from django.conf import settings from django.db import migrations, models import django.db.models.deletion -import django.utils.timezone class Migration(migrations.Migration): @@ -19,15 +18,85 @@ class Migration(migrations.Migration): name='Hackathon', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('created', models.DateTimeField(auto_now_add=True)), ('updated', models.DateTimeField(auto_now=True)), ('display_name', models.CharField(default='', max_length=254)), ('description', models.TextField()), ('start_date', models.DateTimeField()), ('end_date', models.DateTimeField()), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_created', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathons', to=settings.AUTH_USER_MODEL)), ('judges', models.ManyToManyField(blank=True, related_name='hackathon_judges', to=settings.AUTH_USER_MODEL)), ('organiser', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackathon_organiser', to=settings.AUTH_USER_MODEL)), ], ), + migrations.CreateModel( + name='HackProject', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=255)), + ('description', models.TextField()), + ('github_link', models.URLField(default='', max_length=255)), + ('collab_link', models.URLField(default='', max_length=255)), + ('submission_time', models.DateTimeField(auto_now_add=True)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojects', to=settings.AUTH_USER_MODEL)), + ('mentor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='HackTeam', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=254)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteams', to=settings.AUTH_USER_MODEL)), + ('hackathon', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teams', to='hackathon.hackathon')), + ('participants', models.ManyToManyField(related_name='hackteam', to=settings.AUTH_USER_MODEL)), + ('project', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject')), + ], + ), + migrations.CreateModel( + name='HackProjectScoreCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('category', models.CharField(default='', max_length=255)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategories', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name_plural': 'Hack project score categories', + }, + ), + migrations.CreateModel( + name='HackProjectScore', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('score', models.IntegerField(default=0)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL)), + ('hack_project_score_category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory')), + ('judge', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scores', to='hackathon.hackproject')), + ], + ), + migrations.CreateModel( + name='HackAwardCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=254)), + ('description', models.TextField()), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategories', to=settings.AUTH_USER_MODEL)), + ('hackathon', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='awards', to='hackathon.hackathon')), + ('winning_project', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject')), + ], + options={ + 'verbose_name_plural': 'Hack award categories', + }, + ), ] diff --git a/hackathon/migrations/0002_auto_20201015_1936.py b/hackathon/migrations/0002_auto_20201015_1936.py deleted file mode 100644 index c5e81fef..00000000 --- a/hackathon/migrations/0002_auto_20201015_1936.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-15 19:36 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('hackathon', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='hackathon', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_created_by', to=settings.AUTH_USER_MODEL), - ), - migrations.CreateModel( - name='HackAwardCategory', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=254)), - ('description', models.TextField()), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategory_created_by', to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/hackathon/migrations/0003_auto_20201015_2020.py b/hackathon/migrations/0003_auto_20201015_2020.py deleted file mode 100644 index 49c4537f..00000000 --- a/hackathon/migrations/0003_auto_20201015_2020.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-15 20:20 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('hackathon', '0002_auto_20201015_1936'), - ] - - operations = [ - migrations.AlterModelOptions( - name='hackawardcategory', - options={'verbose_name_plural': 'Hack award categories'}, - ), - migrations.CreateModel( - name='HackTeam', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=254)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteam_created_by', to=settings.AUTH_USER_MODEL)), - ('participants', models.ManyToManyField(related_name='hackteam', to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.CreateModel( - name='HackProject', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=255)), - ('description', models.TextField()), - ('github_link', models.CharField(default='', max_length=255)), - ('collab_link', models.CharField(default='', max_length=255)), - ('submission_time', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackproject_created_by', to=settings.AUTH_USER_MODEL)), - ('mentor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/hackathon/migrations/0004_auto_20201015_2224.py b/hackathon/migrations/0004_auto_20201015_2224.py deleted file mode 100644 index 1a3d1081..00000000 --- a/hackathon/migrations/0004_auto_20201015_2224.py +++ /dev/null @@ -1,65 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-15 22:24 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('hackathon', '0003_auto_20201015_2020'), - ] - - operations = [ - migrations.AddField( - model_name='hackawardcategory', - name='hackathon', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='awards', to='hackathon.hackathon'), - preserve_default=False, - ), - migrations.AddField( - model_name='hackawardcategory', - name='winning_project', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject'), - ), - migrations.AddField( - model_name='hackteam', - name='hackathon', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='teams', to='hackathon.hackathon'), - preserve_default=False, - ), - migrations.AddField( - model_name='hackteam', - name='project', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject'), - ), - migrations.CreateModel( - name='HackProjectScoreCategory', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), - ('updated', models.DateTimeField(auto_now=True)), - ('category', models.CharField(default='', max_length=255)), - ('score', models.IntegerField(default=0)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategory_created_by', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'verbose_name_plural': 'Hack project score categories', - }, - ), - migrations.CreateModel( - name='HackProjectScore', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(default=django.utils.timezone.now)), - ('updated', models.DateTimeField(auto_now=True)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscore_created_by', to=settings.AUTH_USER_MODEL)), - ('judge', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scores', to='hackathon.hackproject')), - ('score', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory')), - ], - ), - ] diff --git a/hackathon/migrations/0005_auto_20201016_1951.py b/hackathon/migrations/0005_auto_20201016_1951.py deleted file mode 100644 index 00a23f97..00000000 --- a/hackathon/migrations/0005_auto_20201016_1951.py +++ /dev/null @@ -1,76 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-16 19:51 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('hackathon', '0004_auto_20201015_2224'), - ] - - operations = [ - migrations.RemoveField( - model_name='hackprojectscorecategory', - name='score', - ), - migrations.AddField( - model_name='hackprojectscore', - name='hackprojectscorecategory', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory'), - preserve_default=False, - ), - migrations.AlterField( - model_name='hackathon', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - migrations.AlterField( - model_name='hackawardcategory', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - migrations.AlterField( - model_name='hackawardcategory', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategories', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='hackproject', - name='collab_link', - field=models.URLField(default='', max_length=255), - ), - migrations.AlterField( - model_name='hackproject', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - migrations.AlterField( - model_name='hackproject', - name='github_link', - field=models.URLField(default='', max_length=255), - ), - migrations.AlterField( - model_name='hackprojectscore', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - migrations.AlterField( - model_name='hackprojectscore', - name='score', - field=models.IntegerField(default=0), - ), - migrations.AlterField( - model_name='hackprojectscorecategory', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - migrations.AlterField( - model_name='hackteam', - name='created', - field=models.DateTimeField(auto_now_add=True), - ), - ] diff --git a/hackathon/migrations/0006_auto_20201016_2050.py b/hackathon/migrations/0006_auto_20201016_2050.py deleted file mode 100644 index ccd0d5ac..00000000 --- a/hackathon/migrations/0006_auto_20201016_2050.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-16 20:50 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('hackathon', '0005_auto_20201016_1951'), - ] - - operations = [ - migrations.RenameField( - model_name='hackprojectscore', - old_name='hackprojectscorecategory', - new_name='hack_project_score_category', - ), - ] diff --git a/hackathon/migrations/0007_auto_20201017_1148.py b/hackathon/migrations/0007_auto_20201017_1148.py deleted file mode 100644 index 0144e456..00000000 --- a/hackathon/migrations/0007_auto_20201017_1148.py +++ /dev/null @@ -1,41 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-17 11:48 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('hackathon', '0006_auto_20201016_2050'), - ] - - operations = [ - migrations.AlterField( - model_name='hackathon', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathons', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='hackproject', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojects', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='hackprojectscore', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='hackprojectscorecategory', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategories', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='hackteam', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteams', to=settings.AUTH_USER_MODEL), - ), - ] From 7fb14e9e732f2468345614af9d0286c71c496927 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Mon, 19 Oct 2020 13:06:20 +0100 Subject: [PATCH 14/29] Updated models/forms/admin.py files of accounts app to suit Profile model based on Sean Murphy code and help --- accounts/admin.py | 12 ++++ accounts/forms.py | 1 - accounts/migrations/0001_initial.py | 27 +++++++++ accounts/models.py | 88 ++++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 accounts/migrations/0001_initial.py diff --git a/accounts/admin.py b/accounts/admin.py index 8c38f3f3..8c31e9de 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -1,3 +1,15 @@ from django.contrib import admin +from .models import Profile +from django.contrib.auth.models import User + # Register your models here. +class ProfileAdmin(admin.ModelAdmin): + fields = ( + 'slack_display_name', + 'user_type', + 'current_lms_module', + ) + + +admin.site.register(Profile, ProfileAdmin) diff --git a/accounts/forms.py b/accounts/forms.py index 9b039976..f678b557 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -52,4 +52,3 @@ def custom_signup(self, request, user): user.slack_display_name = self.cleaned_data["slack_display_name"] user.user_type = self.cleaned_data["user_type"] user.current_lms_module = self.cleaned_data["current_lms_module"] - user.save() diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py new file mode 100644 index 00000000..eade302e --- /dev/null +++ b/accounts/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.1 on 2020-10-19 10:01 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('slack_display_name', models.CharField(max_length=80, null=True)), + ('user_type', models.CharField(choices=[('', 'Select Post Category'), ('participant', 'Participant'), ('staff', 'Staff'), ('admin', 'Admin')], max_length=20, null=True)), + ('current_lms_module', models.CharField(choices=[('', 'Select Learning Stage'), ('programme preliminaries', 'Programme Preliminaries'), ('programming paradigms', 'Programming Paradigms'), ('html fundamentals', 'HTML Fundamentals'), ('css fundamentals', 'CSS Fundamentals'), ('user centric frontend development', 'User Centric Frontend Development'), ('javascript fundamentals', 'Javascript Fundamentals'), ('interactive frontend development', 'Interactive Frontend Development'), ('python fundamentals', 'Python Fundamentals'), ('practical python', 'Practical Python'), ('data centric development', 'Data Centric Development'), ('full stack frameworks with django', 'Full Stack Frameworks with Django'), ('alumni', 'Alumni'), ('staff', 'Staff')], max_length=35, null=True)), + ('user', models.OneToOneField(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/accounts/models.py b/accounts/models.py index 7e7941aa..9351f69b 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,11 +1,85 @@ from allauth.account.signals import user_signed_up from django.dispatch import receiver from django.contrib.auth.models import User +from django.db import models +from django.conf import settings +from django.db.models.signals import post_delete + +"""List of user types to be passed into dropdown of same name for each +user selection.""" +user_types = [ + ('', 'Select Post Category'), + ('participant', 'Participant'), + ('staff', 'Staff'), + ('admin', 'Admin'), +] + +"""List of CI LMS modules to be passed into dropdown of same name for each +user selection.""" +lms_modules = [ + ('', 'Select Learning Stage'), + ('programme preliminaries', 'Programme Preliminaries'), + ('programming paradigms', 'Programming Paradigms'), + ('html fundamentals', 'HTML Fundamentals'), + ('css fundamentals', 'CSS Fundamentals'), + ('user centric frontend development', 'User Centric Frontend Development'), + ('javascript fundamentals', 'Javascript Fundamentals'), + ('interactive frontend development', 'Interactive Frontend Development'), + ('python fundamentals', 'Python Fundamentals'), + ('practical python', 'Practical Python'), + ('data centric development', 'Data Centric Development'), + ('full stack frameworks with django', 'Full Stack Frameworks with Django'), + ('alumni', 'Alumni'), + ('staff', 'Staff'), +] + + +class Profile(models.Model): + user = models.OneToOneField( + settings.AUTH_USER_MODEL, default=1, + related_name='profile', + on_delete=models.CASCADE + ) + slack_display_name = models.CharField( + max_length=80, + blank=False, + null=True + ) + user_type = models.CharField( + max_length=20, + blank=False, + null=True, + choices=user_types + ) + current_lms_module = models.CharField( + max_length=35, + blank=False, + null=True, + choices=lms_modules + ) + + def save(self, *args, **kwargs): + # when signup takes place + try: + self.slack_display_name = self.user.slack_display_name + self.user_type = self.user.user_type + self.current_lms_module = self.user.current_lms_module + # when saving via admin panel + except: + self.slack_display_name = self.user.profile.slack_display_name + self.user_type = self.user.profile.user_type + self.current_lms_module = self.user.profile.current_lms_module + + super(Profile, self).save(*args, **kwargs) + + def __str__(self): + return self.user.username @receiver(user_signed_up) def user_signed_up(request, user, **kwargs): - # capture server request object in dict for easy accessing of headers within + # capture server request object in dict from QueryDict, for easy accessing + # of headers within form = dict(request.POST) print(form) # check user_type value for explicit statement and set user active @@ -20,3 +94,15 @@ def user_signed_up(request, user, **kwargs): user.is_staff = True user.is_superuser = True user.save() + + # Save linked instance of user object to profile model + Profile.objects.create(user=user) + + +@receiver(post_delete, sender=Profile) +def post_delete_user(sender, instance, *args, **kwargs): + """ + admin - delete user at same time as profile deletion + """ + if instance: + instance.user.delete() From 15a20ce614ccc0960d28d5092b9111b216fbd6df Mon Sep 17 00:00:00 2001 From: auxfuse Date: Mon, 19 Oct 2020 14:37:45 +0100 Subject: [PATCH 15/29] Manually added migrations files ommited from latest git pull upstream master --- .../migrations/0002_auto_20201015_1936.py | 33 ++++++++ .../migrations/0003_auto_20201015_2020.py | 47 ++++++++++++ .../migrations/0004_auto_20201015_2224.py | 65 ++++++++++++++++ .../migrations/0005_auto_20201016_1951.py | 76 +++++++++++++++++++ .../migrations/0006_auto_20201016_2050.py | 18 +++++ .../migrations/0007_auto_20201017_1148.py | 41 ++++++++++ ..._hackprojectscorecategory_highest_score.py | 2 +- .../migrations/0009_auto_20201018_1829.py | 2 +- 8 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 hackathon/migrations/0002_auto_20201015_1936.py create mode 100644 hackathon/migrations/0003_auto_20201015_2020.py create mode 100644 hackathon/migrations/0004_auto_20201015_2224.py create mode 100644 hackathon/migrations/0005_auto_20201016_1951.py create mode 100644 hackathon/migrations/0006_auto_20201016_2050.py create mode 100644 hackathon/migrations/0007_auto_20201017_1148.py diff --git a/hackathon/migrations/0002_auto_20201015_1936.py b/hackathon/migrations/0002_auto_20201015_1936.py new file mode 100644 index 00000000..ce61ee5d --- /dev/null +++ b/hackathon/migrations/0002_auto_20201015_1936.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1.1 on 2020-10-15 19:36 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='hackathon', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_created_by', to=settings.AUTH_USER_MODEL), + ), + migrations.CreateModel( + name='HackAwardCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=254)), + ('description', models.TextField()), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategory_created_by', to=settings.AUTH_USER_MODEL)), + ], + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0003_auto_20201015_2020.py b/hackathon/migrations/0003_auto_20201015_2020.py new file mode 100644 index 00000000..298b217c --- /dev/null +++ b/hackathon/migrations/0003_auto_20201015_2020.py @@ -0,0 +1,47 @@ +# Generated by Django 3.1.1 on 2020-10-15 20:20 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0002_auto_20201015_1936'), + ] + + operations = [ + migrations.AlterModelOptions( + name='hackawardcategory', + options={'verbose_name_plural': 'Hack award categories'}, + ), + migrations.CreateModel( + name='HackTeam', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=254)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteam_created_by', to=settings.AUTH_USER_MODEL)), + ('participants', models.ManyToManyField(related_name='hackteam', to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='HackProject', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=255)), + ('description', models.TextField()), + ('github_link', models.CharField(default='', max_length=255)), + ('collab_link', models.CharField(default='', max_length=255)), + ('submission_time', models.DateTimeField(auto_now_add=True)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackproject_created_by', to=settings.AUTH_USER_MODEL)), + ('mentor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL)), + ], + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0004_auto_20201015_2224.py b/hackathon/migrations/0004_auto_20201015_2224.py new file mode 100644 index 00000000..7d737e62 --- /dev/null +++ b/hackathon/migrations/0004_auto_20201015_2224.py @@ -0,0 +1,65 @@ +# Generated by Django 3.1.1 on 2020-10-15 22:24 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0003_auto_20201015_2020'), + ] + + operations = [ + migrations.AddField( + model_name='hackawardcategory', + name='hackathon', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='awards', to='hackathon.hackathon'), + preserve_default=False, + ), + migrations.AddField( + model_name='hackawardcategory', + name='winning_project', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject'), + ), + migrations.AddField( + model_name='hackteam', + name='hackathon', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='teams', to='hackathon.hackathon'), + preserve_default=False, + ), + migrations.AddField( + model_name='hackteam', + name='project', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject'), + ), + migrations.CreateModel( + name='HackProjectScoreCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('updated', models.DateTimeField(auto_now=True)), + ('category', models.CharField(default='', max_length=255)), + ('score', models.IntegerField(default=0)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategory_created_by', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name_plural': 'Hack project score categories', + }, + ), + migrations.CreateModel( + name='HackProjectScore', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('updated', models.DateTimeField(auto_now=True)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscore_created_by', to=settings.AUTH_USER_MODEL)), + ('judge', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scores', to='hackathon.hackproject')), + ('score', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory')), + ], + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0005_auto_20201016_1951.py b/hackathon/migrations/0005_auto_20201016_1951.py new file mode 100644 index 00000000..15668605 --- /dev/null +++ b/hackathon/migrations/0005_auto_20201016_1951.py @@ -0,0 +1,76 @@ +# Generated by Django 3.1.1 on 2020-10-16 19:51 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0004_auto_20201015_2224'), + ] + + operations = [ + migrations.RemoveField( + model_name='hackprojectscorecategory', + name='score', + ), + migrations.AddField( + model_name='hackprojectscore', + name='hackprojectscorecategory', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory'), + preserve_default=False, + ), + migrations.AlterField( + model_name='hackathon', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='hackawardcategory', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='hackawardcategory', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategories', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackproject', + name='collab_link', + field=models.URLField(default='', max_length=255), + ), + migrations.AlterField( + model_name='hackproject', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='hackproject', + name='github_link', + field=models.URLField(default='', max_length=255), + ), + migrations.AlterField( + model_name='hackprojectscore', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='hackprojectscore', + name='score', + field=models.IntegerField(default=0), + ), + migrations.AlterField( + model_name='hackprojectscorecategory', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='hackteam', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0006_auto_20201016_2050.py b/hackathon/migrations/0006_auto_20201016_2050.py new file mode 100644 index 00000000..14216dc3 --- /dev/null +++ b/hackathon/migrations/0006_auto_20201016_2050.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-16 20:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0005_auto_20201016_1951'), + ] + + operations = [ + migrations.RenameField( + model_name='hackprojectscore', + old_name='hackprojectscorecategory', + new_name='hack_project_score_category', + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0007_auto_20201017_1148.py b/hackathon/migrations/0007_auto_20201017_1148.py new file mode 100644 index 00000000..17656072 --- /dev/null +++ b/hackathon/migrations/0007_auto_20201017_1148.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.1 on 2020-10-17 11:48 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0006_auto_20201016_2050'), + ] + + operations = [ + migrations.AlterField( + model_name='hackathon', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathons', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackproject', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojects', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackprojectscore', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackprojectscorecategory', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategories', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackteam', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteams', to=settings.AUTH_USER_MODEL), + ), + ] \ No newline at end of file diff --git a/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py b/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py index a6b14d9e..7f1ebfff 100644 --- a/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py +++ b/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py @@ -15,4 +15,4 @@ class Migration(migrations.Migration): name='highest_score', field=models.IntegerField(default=10), ), - ] + ] \ No newline at end of file diff --git a/hackathon/migrations/0009_auto_20201018_1829.py b/hackathon/migrations/0009_auto_20201018_1829.py index c5a2ed8a..a4ddbe5a 100644 --- a/hackathon/migrations/0009_auto_20201018_1829.py +++ b/hackathon/migrations/0009_auto_20201018_1829.py @@ -20,4 +20,4 @@ class Migration(migrations.Migration): name='min_score', field=models.IntegerField(default=1), ), - ] + ] \ No newline at end of file From d375e11c30aba647c6d5fdda9e0d661329695ff6 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Mon, 19 Oct 2020 15:31:00 +0100 Subject: [PATCH 16/29] accounts app files updated with comments throughout, dependant lists moved to lists.py and imported where necessary to reduce duplicate code fragments --- accounts/admin.py | 2 +- accounts/forms.py | 38 ++++++++++-------------------------- accounts/lists.py | 27 ++++++++++++++++++++++++++ accounts/models.py | 48 ++++++++++++++++------------------------------ 4 files changed, 54 insertions(+), 61 deletions(-) create mode 100644 accounts/lists.py diff --git a/accounts/admin.py b/accounts/admin.py index 8c31e9de..ade1af91 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -1,10 +1,10 @@ from django.contrib import admin from .models import Profile -from django.contrib.auth.models import User # Register your models here. class ProfileAdmin(admin.ModelAdmin): + # Defining fields for Admin panel fields = ( 'slack_display_name', 'user_type', diff --git a/accounts/forms.py b/accounts/forms.py index f678b557..94736afb 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,36 +1,17 @@ from allauth.account.forms import SignupForm from django import forms - -"""List of user types to be passed into dropdown of same name for each -user selection.""" -user_types = [ - ('', 'Select Post Category'), - ('participant', 'Participant'), - ('staff', 'Staff'), - ('admin', 'Admin'), -] - -"""List of CI LMS modules to be passed into dropdown of same name for each -user selection.""" -lms_modules = [ - ('', 'Select Learning Stage'), - ('programme preliminaries', 'Programme Preliminaries'), - ('programming paradigms', 'Programming Paradigms'), - ('html fundamentals', 'HTML Fundamentals'), - ('css fundamentals', 'CSS Fundamentals'), - ('user centric frontend development', 'User Centric Frontend Development'), - ('javascript fundamentals', 'Javascript Fundamentals'), - ('interactive frontend development', 'Interactive Frontend Development'), - ('python fundamentals', 'Python Fundamentals'), - ('practical python', 'Practical Python'), - ('data centric development', 'Data Centric Development'), - ('full stack frameworks with django', 'Full Stack Frameworks with Django'), - ('alumni', 'Alumni'), - ('staff', 'Staff'), -] +from .lists import user_types, lms_modules class ExtendedSignupForm(SignupForm): + """ + Extending default Django allauth Signup Form to include fields to capture: + - first name/last name/slack display name/user type/current lms module + + Also, overriding the init method to call the parent class and reset the + autofocus to suit the form updated flow and adding custom + validation logic to suit the additional fields. + """ first_name = forms.CharField(max_length=20) last_name = forms.CharField(max_length=20) slack_display_name = forms.CharField(max_length=25) @@ -43,6 +24,7 @@ class ExtendedSignupForm(SignupForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + # Resetting the form autofocus to 'email' as the first displayed field. self.fields['email'].widget.attrs['autofocus'] = True self.fields['username'].widget.attrs['autofocus'] = False diff --git a/accounts/lists.py b/accounts/lists.py new file mode 100644 index 00000000..572615b2 --- /dev/null +++ b/accounts/lists.py @@ -0,0 +1,27 @@ +# User types list passed into dropdown of same name for user selection used +# in models.py & forms.py +user_types = [ + ('', 'Select Post Category'), + ('participant', 'Participant'), + ('staff', 'Staff'), + ('admin', 'Admin'), +] + +# LMS Modules list passed into dropdown of same name for user selection used +# in modules.py & forms.py +lms_modules = [ + ('', 'Select Learning Stage'), + ('programme preliminaries', 'Programme Preliminaries'), + ('programming paradigms', 'Programming Paradigms'), + ('html fundamentals', 'HTML Fundamentals'), + ('css fundamentals', 'CSS Fundamentals'), + ('user centric frontend development', 'User Centric Frontend Development'), + ('javascript fundamentals', 'Javascript Fundamentals'), + ('interactive frontend development', 'Interactive Frontend Development'), + ('python fundamentals', 'Python Fundamentals'), + ('practical python', 'Practical Python'), + ('data centric development', 'Data Centric Development'), + ('full stack frameworks with django', 'Full Stack Frameworks with Django'), + ('alumni', 'Alumni'), + ('staff', 'Staff'), +] \ No newline at end of file diff --git a/accounts/models.py b/accounts/models.py index 9351f69b..d74339ae 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -4,37 +4,19 @@ from django.db import models from django.conf import settings from django.db.models.signals import post_delete - -"""List of user types to be passed into dropdown of same name for each -user selection.""" -user_types = [ - ('', 'Select Post Category'), - ('participant', 'Participant'), - ('staff', 'Staff'), - ('admin', 'Admin'), -] - -"""List of CI LMS modules to be passed into dropdown of same name for each -user selection.""" -lms_modules = [ - ('', 'Select Learning Stage'), - ('programme preliminaries', 'Programme Preliminaries'), - ('programming paradigms', 'Programming Paradigms'), - ('html fundamentals', 'HTML Fundamentals'), - ('css fundamentals', 'CSS Fundamentals'), - ('user centric frontend development', 'User Centric Frontend Development'), - ('javascript fundamentals', 'Javascript Fundamentals'), - ('interactive frontend development', 'Interactive Frontend Development'), - ('python fundamentals', 'Python Fundamentals'), - ('practical python', 'Practical Python'), - ('data centric development', 'Data Centric Development'), - ('full stack frameworks with django', 'Full Stack Frameworks with Django'), - ('alumni', 'Alumni'), - ('staff', 'Staff'), -] +from .lists import user_types, lms_modules class Profile(models.Model): + """ + Define Profile Model with OneToOne relationship to AUTH_USER_MODEL and + custom fields to suit Signup Form Extending in forms.py replicating same + in DB. + Using "related_name" in the OneToOne relationship between the two models + specifies the reverse relationship to the User Model, allowing us to + target the custom fields for injection into the profile.html + template via `{{ user.profile.<> }}`. + """ user = models.OneToOneField( settings.AUTH_USER_MODEL, default=1, related_name='profile', @@ -78,12 +60,14 @@ def __str__(self): @receiver(user_signed_up) def user_signed_up(request, user, **kwargs): - # capture server request object in dict from QueryDict, for easy accessing - # of headers within + """ + Capture server request object in dict from QueryDict, to access form values. + + Iterate over user_type field value to check for type and set permissions + based on user story and save user to User and Profile Models. + """ form = dict(request.POST) print(form) - # check user_type value for explicit statement and set user active - # permission to true/false if form['user_type'][0] == 'participant': user.is_active = True elif form['user_type'][0] == 'staff': From 15987331d97edeb1baefec03b681d7d38c6167fd Mon Sep 17 00:00:00 2001 From: auxfuse Date: Mon, 19 Oct 2020 16:59:06 +0100 Subject: [PATCH 17/29] Re-added 0001-inital.py hackathon migration file to solve OperationalError --- hackathon/migrations/0001_initial.py | 79 ++-------------------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/hackathon/migrations/0001_initial.py b/hackathon/migrations/0001_initial.py index 27be0f0f..d399594b 100644 --- a/hackathon/migrations/0001_initial.py +++ b/hackathon/migrations/0001_initial.py @@ -1,8 +1,9 @@ -# Generated by Django 3.1.1 on 2020-10-18 20:58 +# Generated by Django 3.1.1 on 2020-10-15 19:02 from django.conf import settings from django.db import migrations, models import django.db.models.deletion +import django.utils.timezone class Migration(migrations.Migration): @@ -18,85 +19,15 @@ class Migration(migrations.Migration): name='Hackathon', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), + ('created', models.DateTimeField(default=django.utils.timezone.now)), ('updated', models.DateTimeField(auto_now=True)), ('display_name', models.CharField(default='', max_length=254)), ('description', models.TextField()), ('start_date', models.DateTimeField()), ('end_date', models.DateTimeField()), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathons', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackathon_created', to=settings.AUTH_USER_MODEL)), ('judges', models.ManyToManyField(blank=True, related_name='hackathon_judges', to=settings.AUTH_USER_MODEL)), ('organiser', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackathon_organiser', to=settings.AUTH_USER_MODEL)), ], ), - migrations.CreateModel( - name='HackProject', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=255)), - ('description', models.TextField()), - ('github_link', models.URLField(default='', max_length=255)), - ('collab_link', models.URLField(default='', max_length=255)), - ('submission_time', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojects', to=settings.AUTH_USER_MODEL)), - ('mentor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.CreateModel( - name='HackTeam', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=254)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackteams', to=settings.AUTH_USER_MODEL)), - ('hackathon', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teams', to='hackathon.hackathon')), - ('participants', models.ManyToManyField(related_name='hackteam', to=settings.AUTH_USER_MODEL)), - ('project', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject')), - ], - ), - migrations.CreateModel( - name='HackProjectScoreCategory', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('category', models.CharField(default='', max_length=255)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscorecategories', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'verbose_name_plural': 'Hack project score categories', - }, - ), - migrations.CreateModel( - name='HackProjectScore', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('score', models.IntegerField(default=0)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL)), - ('hack_project_score_category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hackathon.hackprojectscorecategory')), - ('judge', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scores', to='hackathon.hackproject')), - ], - ), - migrations.CreateModel( - name='HackAwardCategory', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('display_name', models.CharField(default='', max_length=254)), - ('description', models.TextField()), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackawardcategories', to=settings.AUTH_USER_MODEL)), - ('hackathon', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='awards', to='hackathon.hackathon')), - ('winning_project', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hackathon.hackproject')), - ], - options={ - 'verbose_name_plural': 'Hack award categories', - }, - ), - ] + ] \ No newline at end of file From f7db24453a0d10f2dd4066db7fa3c788b3f8d162 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 12:46:58 +0100 Subject: [PATCH 18/29] Refactored accounts .py files to change lists to constants, set user registration and login to only reference email instead of username, and separated imports into 3rd party and local blocks --- accounts/admin.py | 1 + accounts/forms.py | 10 +++++----- accounts/lists.py | 28 ++++++++++++++-------------- accounts/models.py | 11 ++++++----- accounts/tests.py | 2 -- accounts/views.py | 2 -- main/settings.py | 3 ++- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/accounts/admin.py b/accounts/admin.py index ade1af91..3d6a0996 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Profile diff --git a/accounts/forms.py b/accounts/forms.py index 94736afb..91f331ef 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,6 +1,7 @@ -from allauth.account.forms import SignupForm from django import forms -from .lists import user_types, lms_modules +from allauth.account.forms import SignupForm + +from .lists import USER_TYPES_CHOICES, LMS_MODULES_CHOICES class ExtendedSignupForm(SignupForm): @@ -16,17 +17,16 @@ class ExtendedSignupForm(SignupForm): last_name = forms.CharField(max_length=20) slack_display_name = forms.CharField(max_length=25) user_type = forms.ChoiceField( - choices=user_types + choices=USER_TYPES_CHOICES ) current_lms_module = forms.ChoiceField( - choices=lms_modules + choices=LMS_MODULES_CHOICES ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Resetting the form autofocus to 'email' as the first displayed field. self.fields['email'].widget.attrs['autofocus'] = True - self.fields['username'].widget.attrs['autofocus'] = False def custom_signup(self, request, user): user.first_name = self.cleaned_data["first_name"] diff --git a/accounts/lists.py b/accounts/lists.py index 572615b2..00f65255 100644 --- a/accounts/lists.py +++ b/accounts/lists.py @@ -1,6 +1,6 @@ # User types list passed into dropdown of same name for user selection used # in models.py & forms.py -user_types = [ +USER_TYPES_CHOICES = [ ('', 'Select Post Category'), ('participant', 'Participant'), ('staff', 'Staff'), @@ -9,19 +9,19 @@ # LMS Modules list passed into dropdown of same name for user selection used # in modules.py & forms.py -lms_modules = [ +LMS_MODULES_CHOICES = [ ('', 'Select Learning Stage'), - ('programme preliminaries', 'Programme Preliminaries'), - ('programming paradigms', 'Programming Paradigms'), - ('html fundamentals', 'HTML Fundamentals'), - ('css fundamentals', 'CSS Fundamentals'), - ('user centric frontend development', 'User Centric Frontend Development'), - ('javascript fundamentals', 'Javascript Fundamentals'), - ('interactive frontend development', 'Interactive Frontend Development'), - ('python fundamentals', 'Python Fundamentals'), - ('practical python', 'Practical Python'), - ('data centric development', 'Data Centric Development'), - ('full stack frameworks with django', 'Full Stack Frameworks with Django'), + ('programme_preliminaries', 'Programme Preliminaries'), + ('programming_paradigms', 'Programming Paradigms'), + ('html_fundamentals', 'HTML Fundamentals'), + ('css_fundamentals', 'CSS Fundamentals'), + ('user_centric_frontend_development', 'User Centric Frontend Development'), + ('javascript_fundamentals', 'Javascript Fundamentals'), + ('interactive_frontend_development', 'Interactive Frontend Development'), + ('python_fundamentals', 'Python Fundamentals'), + ('practical_python', 'Practical Python'), + ('data_centric_development', 'Data Centric Development'), + ('full_stack_frameworks with django', 'Full Stack Frameworks with Django'), ('alumni', 'Alumni'), ('staff', 'Staff'), -] \ No newline at end of file +] diff --git a/accounts/models.py b/accounts/models.py index d74339ae..26acc618 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,10 +1,11 @@ -from allauth.account.signals import user_signed_up from django.dispatch import receiver from django.contrib.auth.models import User from django.db import models from django.conf import settings from django.db.models.signals import post_delete -from .lists import user_types, lms_modules +from allauth.account.signals import user_signed_up + +from .lists import USER_TYPES_CHOICES, LMS_MODULES_CHOICES class Profile(models.Model): @@ -31,13 +32,13 @@ class Profile(models.Model): max_length=20, blank=False, null=True, - choices=user_types + choices=USER_TYPES_CHOICES ) current_lms_module = models.CharField( max_length=35, blank=False, null=True, - choices=lms_modules + choices=LMS_MODULES_CHOICES ) def save(self, *args, **kwargs): @@ -67,7 +68,7 @@ def user_signed_up(request, user, **kwargs): based on user story and save user to User and Profile Models. """ form = dict(request.POST) - print(form) + if form['user_type'][0] == 'participant': user.is_active = True elif form['user_type'][0] == 'staff': diff --git a/accounts/tests.py b/accounts/tests.py index 7ce503c2..2e9cb5f6 100644 --- a/accounts/tests.py +++ b/accounts/tests.py @@ -1,3 +1 @@ from django.test import TestCase - -# Create your tests here. diff --git a/accounts/views.py b/accounts/views.py index 91ea44a2..2536b376 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,3 +1 @@ from django.shortcuts import render - -# Create your views here. diff --git a/main/settings.py b/main/settings.py index 31cc445a..8a28f186 100644 --- a/main/settings.py +++ b/main/settings.py @@ -85,7 +85,8 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ACCOUNT_FORMS = {'signup': 'accounts.forms.ExtendedSignupForm'} -ACCOUNT_AUTHENTICATION_METHOD = 'username_email' +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE = True From 0d8968d5df52a415a681a3248a0611906da92251 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 12:52:37 +0100 Subject: [PATCH 19/29] Updated accounts/models.py file with CharField null value to be '' as per Django documentation and reflected email login use over username in str object --- accounts/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accounts/models.py b/accounts/models.py index 26acc618..e75d92d8 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -26,18 +26,18 @@ class Profile(models.Model): slack_display_name = models.CharField( max_length=80, blank=False, - null=True + null='' ) user_type = models.CharField( max_length=20, blank=False, - null=True, + null='', choices=USER_TYPES_CHOICES ) current_lms_module = models.CharField( max_length=35, blank=False, - null=True, + null='', choices=LMS_MODULES_CHOICES ) @@ -56,7 +56,7 @@ def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) def __str__(self): - return self.user.username + return self.user.email @receiver(user_signed_up) From 8ebdf18a092e7faed99c000d8f9f8de2cfe9462f Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 13:10:40 +0100 Subject: [PATCH 20/29] Removed unnecessary comment from accounts/admin.py file and added additional trailing blank line to see if Github picks them up --- accounts/admin.py | 2 +- accounts/forms.py | 1 + accounts/lists.py | 1 + accounts/models.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/accounts/admin.py b/accounts/admin.py index 3d6a0996..5bfc7dbb 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -3,7 +3,6 @@ from .models import Profile -# Register your models here. class ProfileAdmin(admin.ModelAdmin): # Defining fields for Admin panel fields = ( @@ -14,3 +13,4 @@ class ProfileAdmin(admin.ModelAdmin): admin.site.register(Profile, ProfileAdmin) + diff --git a/accounts/forms.py b/accounts/forms.py index 91f331ef..89a1d057 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -34,3 +34,4 @@ def custom_signup(self, request, user): user.slack_display_name = self.cleaned_data["slack_display_name"] user.user_type = self.cleaned_data["user_type"] user.current_lms_module = self.cleaned_data["current_lms_module"] + diff --git a/accounts/lists.py b/accounts/lists.py index 00f65255..12d1a0a5 100644 --- a/accounts/lists.py +++ b/accounts/lists.py @@ -25,3 +25,4 @@ ('alumni', 'Alumni'), ('staff', 'Staff'), ] + diff --git a/accounts/models.py b/accounts/models.py index e75d92d8..f1b8683a 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -91,3 +91,4 @@ def post_delete_user(sender, instance, *args, **kwargs): """ if instance: instance.user.delete() + From ada3d3005fe0fce4a2f2bbd8ea0fbb62bd1a7846 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 16:18:53 +0100 Subject: [PATCH 21/29] Default Django allauth authentication templates formatted with IDE formatter, adding appropriate indentation. --- .../allauth/account/account_inactive.html | 5 +- templates/allauth/account/email.html | 100 +++++++++--------- templates/allauth/account/email_confirm.html | 36 +++---- templates/allauth/account/login.html | 67 ++++++------ templates/allauth/account/logout.html | 20 ++-- templates/allauth/account/password_reset.html | 6 +- .../allauth/account/password_reset_done.html | 5 +- .../account/password_reset_from_key.html | 3 +- templates/allauth/account/signup.html | 21 ++-- templates/allauth/account/signup_closed.html | 5 +- .../allauth/account/verification_sent.html | 4 +- .../account/verified_email_required.html | 26 +++-- 12 files changed, 138 insertions(+), 160 deletions(-) diff --git a/templates/allauth/account/account_inactive.html b/templates/allauth/account/account_inactive.html index 3347f4fd..4831310e 100644 --- a/templates/allauth/account/account_inactive.html +++ b/templates/allauth/account/account_inactive.html @@ -5,7 +5,6 @@ {% block head_title %}{% trans "Account Inactive" %}{% endblock %} {% block content %} -

    {% trans "Account Inactive" %}

    - -

    {% trans "This account is inactive." %}

    +

    {% trans "Account Inactive" %}

    +

    {% trans "This account is inactive." %}

    {% endblock %} diff --git a/templates/allauth/account/email.html b/templates/allauth/account/email.html index 9a9ed1f8..00b09099 100644 --- a/templates/allauth/account/email.html +++ b/templates/allauth/account/email.html @@ -6,68 +6,66 @@ {% block content %}

    {% trans "E-mail Addresses" %}

    -{% if user.emailaddress_set.all %} -

    {% trans 'The following e-mail addresses are associated with your account:' %}

    + {% if user.emailaddress_set.all %} +

    + {% trans 'The following e-mail addresses are associated with your account:' %} +

    + - - -{% else %} -

    {% trans 'Warning:'%} {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}

    - -{% endif %} -

    {% trans "Add E-mail Address" %}

    -
    {% csrf_token %} {{ form.as_p }}
    - {% endblock %} - {% block extra_body %} - + {% endblock %} diff --git a/templates/allauth/account/email_confirm.html b/templates/allauth/account/email_confirm.html index ac0891b5..a1e88c67 100644 --- a/templates/allauth/account/email_confirm.html +++ b/templates/allauth/account/email_confirm.html @@ -5,27 +5,19 @@ {% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} - {% block content %} -

    {% trans "Confirm E-mail Address" %}

    - -{% if confirmation %} - -{% user_display confirmation.email_address.user as user_display %} - -

    {% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}

    - -
    -{% csrf_token %} - -
    - -{% else %} - -{% url 'account_email' as email_url %} - -

    {% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request.{% endblocktrans %}

    - -{% endif %} - +

    {% trans "Confirm E-mail Address" %}

    + {% if confirmation %} + {% user_display confirmation.email_address.user as user_display %} +

    {% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address + for user {{ user_display }}.{% endblocktrans %}

    +
    + {% csrf_token %} + +
    + {% else %} + {% url 'account_email' as email_url %} +

    {% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request + .{% endblocktrans %}

    + {% endif %} {% endblock %} diff --git a/templates/allauth/account/login.html b/templates/allauth/account/login.html index 17bc3a6a..1ad77536 100644 --- a/templates/allauth/account/login.html +++ b/templates/allauth/account/login.html @@ -7,40 +7,37 @@ {% block content %} -

    {% trans "Sign In" %}

    - -{% get_providers as socialaccount_providers %} - -{% if socialaccount_providers %} -

    {% blocktrans with site.name as site_name %}Please sign in with one -of your existing third party accounts. Or, sign up -for a {{ site_name }} account and sign in below:{% endblocktrans %}

    - -
    - -
      - {% include "socialaccount/snippets/provider_list.html" with process="login" %} -
    - - - -
    - -{% include "socialaccount/snippets/login_extra.html" %} - -{% else %} -

    {% blocktrans %}If you have not created an account yet, then please -sign up first.{% endblocktrans %}

    -{% endif %} - - +

    {% trans "Sign In" %}

    + + {% get_providers as socialaccount_providers %} + + {% if socialaccount_providers %} +

    {% blocktrans with site.name as site_name %}Please sign in with one + of your existing third party accounts. Or, sign up + for a {{ site_name }} account and sign in below:{% endblocktrans %} +

    +
    +
      + {% include "socialaccount/snippets/provider_list.html" with process="login" %} +
    + +
    + + {% include "socialaccount/snippets/login_extra.html" %} + + {% else %} +

    {% blocktrans %}If you have not created an account yet, then please + sign up first.{% endblocktrans %}

    + {% endif %} + + {% endblock %} diff --git a/templates/allauth/account/logout.html b/templates/allauth/account/logout.html index 2549a901..9c362f98 100644 --- a/templates/allauth/account/logout.html +++ b/templates/allauth/account/logout.html @@ -5,17 +5,15 @@ {% block head_title %}{% trans "Sign Out" %}{% endblock %} {% block content %} -

    {% trans "Sign Out" %}

    - -

    {% trans 'Are you sure you want to sign out?' %}

    - -
    - {% csrf_token %} - {% if redirect_field_value %} - - {% endif %} - -
    +

    {% trans "Sign Out" %}

    +

    {% trans 'Are you sure you want to sign out?' %}

    +
    + {% csrf_token %} + {% if redirect_field_value %} + + {% endif %} + +
    {% endblock %} diff --git a/templates/allauth/account/password_reset.html b/templates/allauth/account/password_reset.html index de23d9eb..b6f0791e 100644 --- a/templates/allauth/account/password_reset.html +++ b/templates/allauth/account/password_reset.html @@ -6,18 +6,16 @@ {% block head_title %}{% trans "Password Reset" %}{% endblock %} {% block content %} -

    {% trans "Password Reset" %}

    {% if user.is_authenticated %} - {% include "account/snippets/already_logged_in.html" %} + {% include "account/snippets/already_logged_in.html" %} {% endif %} -

    {% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

    {% csrf_token %} {{ form.as_p }} - +

    {% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}

    diff --git a/templates/allauth/account/password_reset_done.html b/templates/allauth/account/password_reset_done.html index e90504f7..16cfffc4 100644 --- a/templates/allauth/account/password_reset_done.html +++ b/templates/allauth/account/password_reset_done.html @@ -7,10 +7,9 @@ {% block content %}

    {% trans "Password Reset" %}

    - {% if user.is_authenticated %} - {% include "account/snippets/already_logged_in.html" %} + {% include "account/snippets/already_logged_in.html" %} {% endif %} - +

    {% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

    {% endblock %} diff --git a/templates/allauth/account/password_reset_from_key.html b/templates/allauth/account/password_reset_from_key.html index 16f27e9c..4862683d 100644 --- a/templates/allauth/account/password_reset_from_key.html +++ b/templates/allauth/account/password_reset_from_key.html @@ -8,7 +8,8 @@

    {% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Passwor {% if token_fail %} {% url 'account_reset_password' as passwd_reset_url %} -

    {% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

    +

    {% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a + new password reset.{% endblocktrans %}

    {% else %} {% if form %}
    diff --git a/templates/allauth/account/signup.html b/templates/allauth/account/signup.html index 8b53b442..2e3b9dcb 100644 --- a/templates/allauth/account/signup.html +++ b/templates/allauth/account/signup.html @@ -5,17 +5,16 @@ {% block head_title %}{% trans "Signup" %}{% endblock %} {% block content %} -

    {% trans "Sign Up" %}

    +

    {% trans "Sign Up" %}

    +

    {% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

    -

    {% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

    - - - {% csrf_token %} - {{ form.as_p }} - {% if redirect_field_value %} - - {% endif %} - -
    + {% endblock %} diff --git a/templates/allauth/account/signup_closed.html b/templates/allauth/account/signup_closed.html index bc839506..af258d1b 100644 --- a/templates/allauth/account/signup_closed.html +++ b/templates/allauth/account/signup_closed.html @@ -5,7 +5,6 @@ {% block head_title %}{% trans "Sign Up Closed" %}{% endblock %} {% block content %} -

    {% trans "Sign Up Closed" %}

    - -

    {% trans "We are sorry, but the sign up is currently closed." %}

    +

    {% trans "Sign Up Closed" %}

    +

    {% trans "We are sorry, but the sign up is currently closed." %}

    {% endblock %} diff --git a/templates/allauth/account/verification_sent.html b/templates/allauth/account/verification_sent.html index 5f713319..a7c3d16b 100644 --- a/templates/allauth/account/verification_sent.html +++ b/templates/allauth/account/verification_sent.html @@ -6,7 +6,7 @@ {% block content %}

    {% trans "Verify Your E-mail Address" %}

    - -

    {% blocktrans %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

    +

    {% blocktrans %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not + receive it within a few minutes.{% endblocktrans %}

    {% endblock %} diff --git a/templates/allauth/account/verified_email_required.html b/templates/allauth/account/verified_email_required.html index 8115c489..9d8ab04a 100644 --- a/templates/allauth/account/verified_email_required.html +++ b/templates/allauth/account/verified_email_required.html @@ -5,19 +5,17 @@ {% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} {% block content %} -

    {% trans "Verify Your E-mail Address" %}

    - -{% url 'account_email' as email_url %} - -

    {% blocktrans %}This part of the site requires us to verify that -you are who you claim to be. For this purpose, we require that you -verify ownership of your e-mail address. {% endblocktrans %}

    - -

    {% blocktrans %}We have sent an e-mail to you for -verification. Please click on the link inside this e-mail. Please -contact us if you do not receive it within a few minutes.{% endblocktrans %}

    - -

    {% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}

    - +

    {% trans "Verify Your E-mail Address" %}

    + {% url 'account_email' as email_url %} +

    {% blocktrans %}This part of the site requires us to verify that + you are who you claim to be. For this purpose, we require that you + verify ownership of your e-mail address. {% endblocktrans %} +

    +

    {% blocktrans %}We have sent an e-mail to you for + verification. Please click on the link inside this e-mail. Please + contact us if you do not receive it within a few minutes.{% endblocktrans %} +

    +

    {% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %} +

    {% endblock %} From ce4cc3e243d3a1b63ecd9c50948a3d050ab434f3 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 16:22:25 +0100 Subject: [PATCH 22/29] Formatted allauth socialAccount templates with IDE formatter including snippets --- .../account/snippets/already_logged_in.html | 4 +- .../socialaccount/authentication_error.html | 5 +- .../allauth/socialaccount/connections.html | 86 +++++++++---------- .../socialaccount/login_cancelled.html | 11 +-- templates/allauth/socialaccount/signup.html | 21 +++-- .../socialaccount/snippets/provider_list.html | 28 +++--- 6 files changed, 74 insertions(+), 81 deletions(-) diff --git a/templates/allauth/account/snippets/already_logged_in.html b/templates/allauth/account/snippets/already_logged_in.html index 00799f00..30a8ce1b 100644 --- a/templates/allauth/account/snippets/already_logged_in.html +++ b/templates/allauth/account/snippets/already_logged_in.html @@ -2,4 +2,6 @@ {% load account %} {% user_display user as user_display %} -

    {% trans "Note" %}: {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %}

    +

    + {% trans "Note" %}: {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %} +

    diff --git a/templates/allauth/socialaccount/authentication_error.html b/templates/allauth/socialaccount/authentication_error.html index 03002955..a936d769 100644 --- a/templates/allauth/socialaccount/authentication_error.html +++ b/templates/allauth/socialaccount/authentication_error.html @@ -5,7 +5,6 @@ {% block head_title %}{% trans "Social Network Login Failure" %}{% endblock %} {% block content %} -

    {% trans "Social Network Login Failure" %}

    - -

    {% trans "An error occurred while attempting to login via your social network account." %}

    +

    {% trans "Social Network Login Failure" %}

    +

    {% trans "An error occurred while attempting to login via your social network account." %}

    {% endblock %} diff --git a/templates/allauth/socialaccount/connections.html b/templates/allauth/socialaccount/connections.html index f7c2729f..939291da 100644 --- a/templates/allauth/socialaccount/connections.html +++ b/templates/allauth/socialaccount/connections.html @@ -5,50 +5,46 @@ {% block head_title %}{% trans "Account Connections" %}{% endblock %} {% block content %} -

    {% trans "Account Connections" %}

    - -{% if form.accounts %} -

    {% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}

    - - -
    -{% csrf_token %} - -
    -{% if form.non_field_errors %} -
    {{ form.non_field_errors }}
    -{% endif %} - -{% for base_account in form.accounts %} -{% with base_account.get_provider_account as account %} -
    - -
    -{% endwith %} -{% endfor %} - -
    - -
    - -
    - -
    - -{% else %} -

    {% trans 'You currently have no social network accounts connected to this account.' %}

    -{% endif %} - -

    {% trans 'Add a 3rd Party Account' %}

    - -
      -{% include "socialaccount/snippets/provider_list.html" with process="connect" %} -
    - -{% include "socialaccount/snippets/login_extra.html" %} +

    {% trans "Account Connections" %}

    + {% if form.accounts %} +

    {% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}

    + +
    + {% csrf_token %} + +
    + {% if form.non_field_errors %} +
    {{ form.non_field_errors }}
    + {% endif %} + + {% for base_account in form.accounts %} + {% with base_account.get_provider_account as account %} +
    + +
    + {% endwith %} + {% endfor %} + +
    + +
    +
    +
    + + {% else %} +

    {% trans 'You currently have no social network accounts connected to this account.' %}

    + {% endif %} + +

    {% trans 'Add a 3rd Party Account' %}

    + +
      + {% include "socialaccount/snippets/provider_list.html" with process="connect" %} +
    + + {% include "socialaccount/snippets/login_extra.html" %} {% endblock %} diff --git a/templates/allauth/socialaccount/login_cancelled.html b/templates/allauth/socialaccount/login_cancelled.html index 8d767865..50b9a361 100644 --- a/templates/allauth/socialaccount/login_cancelled.html +++ b/templates/allauth/socialaccount/login_cancelled.html @@ -5,11 +5,8 @@ {% block head_title %}{% trans "Login Cancelled" %}{% endblock %} {% block content %} - -

    {% trans "Login Cancelled" %}

    - -{% url 'account_login' as login_url %} - -

    {% blocktrans %}You decided to cancel logging in to our site using one of your existing accounts. If this was a mistake, please proceed to sign in.{% endblocktrans %}

    - +

    {% trans "Login Cancelled" %}

    + {% url 'account_login' as login_url %} +

    {% blocktrans %}You decided to cancel logging in to our site using one of your existing accounts. If this was a mistake, please proceed to + sign in.{% endblocktrans %}

    {% endblock %} diff --git a/templates/allauth/socialaccount/signup.html b/templates/allauth/socialaccount/signup.html index caa2de2e..1d150146 100644 --- a/templates/allauth/socialaccount/signup.html +++ b/templates/allauth/socialaccount/signup.html @@ -6,17 +6,16 @@ {% block content %}

    {% trans "Sign Up" %}

    +

    {% blocktrans with provider_name=account.get_provider.name site_name=site.name %}You are about to use your {{ provider_name }} account to login to + {{ site_name }}. As a final step, please complete the following form:{% endblocktrans %}

    -

    {% blocktrans with provider_name=account.get_provider.name site_name=site.name %}You are about to use your {{provider_name}} account to login to -{{site_name}}. As a final step, please complete the following form:{% endblocktrans %}

    - - + {% endblock %} diff --git a/templates/allauth/socialaccount/snippets/provider_list.html b/templates/allauth/socialaccount/snippets/provider_list.html index e76a2969..33afe9ac 100644 --- a/templates/allauth/socialaccount/snippets/provider_list.html +++ b/templates/allauth/socialaccount/snippets/provider_list.html @@ -3,18 +3,18 @@ {% get_providers as socialaccount_providers %} {% for provider in socialaccount_providers %} -{% if provider.id == "openid" %} -{% for brand in provider.get_brands %} -
  • - {{brand.name}} -
  • -{% endfor %} -{% endif %} -
  • - {{provider.name}} -
  • + {% if provider.id == "openid" %} + {% for brand in provider.get_brands %} +
  • + {{ brand.name }} +
  • + {% endfor %} + {% endif %} +
  • + {{ provider.name }} +
  • {% endfor %} From de75a0c51ec9f0d41fff4e2597a04ed962b75a98 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 16:25:05 +0100 Subject: [PATCH 23/29] Formatted Django allauth base.html template with default IDE formatter --- templates/allauth/base.html | 68 +++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/templates/allauth/base.html b/templates/allauth/base.html index 4e125162..4138b2e6 100644 --- a/templates/allauth/base.html +++ b/templates/allauth/base.html @@ -1,40 +1,42 @@ - - {% block head_title %}{% endblock %} - {% block extra_head %} - {% endblock %} - - + + {% block head_title %}{% endblock %} + {% block extra_head %} + {% endblock %} + + {% block body %} - {% if messages %} -
    - Messages: -
      - {% for message in messages %} -
    • {{message}}
    • - {% endfor %} -
    -
    - {% endif %} - -
    - Menu: -
      - {% if user.is_authenticated %} -
    • Change E-mail
    • -
    • Sign Out
    • - {% else %} -
    • Sign In
    • -
    • Sign Up
    • + {% if messages %} +
      + Messages: +
        + {% for message in messages %} +
      • {{ message }}
      • + {% endfor %} +
      +
      {% endif %} -
    -
    - {% block content %} - {% endblock %} - {% endblock %} - {% block extra_body %} + +
    + Menu: + +
    + + {% block content %} + {% endblock %} + {% endblock %} - + {% block extra_body %} + {% endblock %} + From af7de06561cc8f89ff1c101d77285bcc8a10c0aa Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 16:36:43 +0100 Subject: [PATCH 24/29] Django allauth email & messages .txt template files formatted manually for increased code readability --- .../email/email_confirmation_message.txt | 19 ++++++++++++---- .../email/password_reset_key_message.txt | 22 ++++++++++++++----- .../email/password_reset_key_subject.txt | 1 + .../messages/cannot_delete_primary_email.txt | 5 ++++- .../messages/email_confirmation_sent.txt | 5 ++++- .../account/messages/email_confirmed.txt | 5 ++++- .../account/messages/email_deleted.txt | 5 ++++- .../allauth/account/messages/logged_in.txt | 7 +++++- .../allauth/account/messages/logged_out.txt | 5 ++++- .../account/messages/password_changed.txt | 5 ++++- .../allauth/account/messages/password_set.txt | 5 ++++- .../account/messages/primary_email_set.txt | 5 ++++- .../messages/unverified_primary_email.txt | 5 ++++- 13 files changed, 75 insertions(+), 19 deletions(-) diff --git a/templates/allauth/account/email/email_confirmation_message.txt b/templates/allauth/account/email/email_confirmation_message.txt index 2d856f76..c3fc2b57 100644 --- a/templates/allauth/account/email/email_confirmation_message.txt +++ b/templates/allauth/account/email/email_confirmation_message.txt @@ -1,9 +1,20 @@ -{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}! +{% load account %} -You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account. +{% user_display user as user_display %} + +{% load i18n %} +{% autoescape off %} + +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %} +Hello from {{ site_name }}! +You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account. To confirm this is correct, go to {{ activate_url }} {% endblocktrans %} -{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }}! -{{ site_domain }}{% endblocktrans %} + +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %} +Thank you from {{ site_name }}! +{{ site_domain }} +{% endblocktrans %} + {% endautoescape %} diff --git a/templates/allauth/account/email/password_reset_key_message.txt b/templates/allauth/account/email/password_reset_key_message.txt index d74dfa82..4e39b43a 100644 --- a/templates/allauth/account/email/password_reset_key_message.txt +++ b/templates/allauth/account/email/password_reset_key_message.txt @@ -1,12 +1,24 @@ -{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}! +{% load i18n %} +{% autoescape off %} + +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %} +Hello from {{ site_name }}! You're receiving this e-mail because you or someone else has requested a password for your user account. -It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %} +It can be safely ignored if you did not request a password reset. Click the link below to reset your password. +{% endblocktrans %} {{ password_reset_url }} -{% if username %}{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %} +{% if username %} +{% blocktrans %} +In case you forgot, your username is {{ username }}. +{% endblocktrans %} +{% endif %} + +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %} +Thank you for using {{ site_name }}! +{{ site_domain }} +{% endblocktrans %} -{% endif %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}! -{{ site_domain }}{% endblocktrans %} {% endautoescape %} diff --git a/templates/allauth/account/email/password_reset_key_subject.txt b/templates/allauth/account/email/password_reset_key_subject.txt index 6840c40b..6857d700 100644 --- a/templates/allauth/account/email/password_reset_key_subject.txt +++ b/templates/allauth/account/email/password_reset_key_subject.txt @@ -1,4 +1,5 @@ {% load i18n %} + {% autoescape off %} {% blocktrans %}Password Reset E-mail{% endblocktrans %} {% endautoescape %} diff --git a/templates/allauth/account/messages/cannot_delete_primary_email.txt b/templates/allauth/account/messages/cannot_delete_primary_email.txt index de555712..0965e23a 100644 --- a/templates/allauth/account/messages/cannot_delete_primary_email.txt +++ b/templates/allauth/account/messages/cannot_delete_primary_email.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}You cannot remove your primary e-mail address ({{email}}).{% endblocktrans %} + +{% blocktrans %} +You cannot remove your primary e-mail address ({{email}}). +{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_confirmation_sent.txt b/templates/allauth/account/messages/email_confirmation_sent.txt index 7a526f8b..ddb9838b 100644 --- a/templates/allauth/account/messages/email_confirmation_sent.txt +++ b/templates/allauth/account/messages/email_confirmation_sent.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Confirmation e-mail sent to {{email}}.{% endblocktrans %} + +{% blocktrans %} +Confirmation e-mail sent to {{email}}. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_confirmed.txt b/templates/allauth/account/messages/email_confirmed.txt index 3427a4d8..a0ace37c 100644 --- a/templates/allauth/account/messages/email_confirmed.txt +++ b/templates/allauth/account/messages/email_confirmed.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}You have confirmed {{email}}.{% endblocktrans %} + +{% blocktrans %} +You have confirmed {{email}}. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/email_deleted.txt b/templates/allauth/account/messages/email_deleted.txt index 5cf7cf91..e189dd9c 100644 --- a/templates/allauth/account/messages/email_deleted.txt +++ b/templates/allauth/account/messages/email_deleted.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Removed e-mail address {{email}}.{% endblocktrans %} + +{% blocktrans %} +Removed e-mail address {{email}}. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/logged_in.txt b/templates/allauth/account/messages/logged_in.txt index f49248a7..ae1f5d86 100644 --- a/templates/allauth/account/messages/logged_in.txt +++ b/templates/allauth/account/messages/logged_in.txt @@ -1,4 +1,9 @@ {% load account %} + {% load i18n %} + {% user_display user as name %} -{% blocktrans %}Successfully signed in as {{name}}.{% endblocktrans %} + +{% blocktrans %} +Successfully signed in as {{name}}. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/logged_out.txt b/templates/allauth/account/messages/logged_out.txt index 2cd4627d..8f9852ec 100644 --- a/templates/allauth/account/messages/logged_out.txt +++ b/templates/allauth/account/messages/logged_out.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}You have signed out.{% endblocktrans %} + +{% blocktrans %} +You have signed out. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/password_changed.txt b/templates/allauth/account/messages/password_changed.txt index bd5801c4..fee92f31 100644 --- a/templates/allauth/account/messages/password_changed.txt +++ b/templates/allauth/account/messages/password_changed.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Password successfully changed.{% endblocktrans %} + +{% blocktrans %} +Password successfully changed. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/password_set.txt b/templates/allauth/account/messages/password_set.txt index 9d224ee0..fbc7fe10 100644 --- a/templates/allauth/account/messages/password_set.txt +++ b/templates/allauth/account/messages/password_set.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Password successfully set.{% endblocktrans %} + +{% blocktrans %} +Password successfully set. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/primary_email_set.txt b/templates/allauth/account/messages/primary_email_set.txt index b6a70dd6..d0c815b7 100644 --- a/templates/allauth/account/messages/primary_email_set.txt +++ b/templates/allauth/account/messages/primary_email_set.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Primary e-mail address set.{% endblocktrans %} + +{% blocktrans %} +Primary e-mail address set. +{% endblocktrans %} diff --git a/templates/allauth/account/messages/unverified_primary_email.txt b/templates/allauth/account/messages/unverified_primary_email.txt index 9c9d0d87..d401af7d 100644 --- a/templates/allauth/account/messages/unverified_primary_email.txt +++ b/templates/allauth/account/messages/unverified_primary_email.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}Your primary e-mail address must be verified.{% endblocktrans %} + +{% blocktrans %} +Your primary e-mail address must be verified. +{% endblocktrans %} From 1fa6f5c92a5169a9c640a4a982b94f043a4674fc Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 16:38:51 +0100 Subject: [PATCH 25/29] Django allauth socialaccounts messages .txt file templates manually formatted for increased code readability --- .../allauth/socialaccount/messages/account_connected.txt | 5 ++++- .../socialaccount/messages/account_connected_other.txt | 5 ++++- .../allauth/socialaccount/messages/account_disconnected.txt | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/templates/allauth/socialaccount/messages/account_connected.txt b/templates/allauth/socialaccount/messages/account_connected.txt index be6aa60f..b3760093 100644 --- a/templates/allauth/socialaccount/messages/account_connected.txt +++ b/templates/allauth/socialaccount/messages/account_connected.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}The social account has been connected.{% endblocktrans %} + +{% blocktrans %} +The social account has been connected. +{% endblocktrans %} diff --git a/templates/allauth/socialaccount/messages/account_connected_other.txt b/templates/allauth/socialaccount/messages/account_connected_other.txt index e90f6ccc..635bab26 100644 --- a/templates/allauth/socialaccount/messages/account_connected_other.txt +++ b/templates/allauth/socialaccount/messages/account_connected_other.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}The social account is already connected to a different account.{% endblocktrans %} + +{% blocktrans %} +The social account is already connected to a different account. +{% endblocktrans %} diff --git a/templates/allauth/socialaccount/messages/account_disconnected.txt b/templates/allauth/socialaccount/messages/account_disconnected.txt index fd43f30e..60a71386 100644 --- a/templates/allauth/socialaccount/messages/account_disconnected.txt +++ b/templates/allauth/socialaccount/messages/account_disconnected.txt @@ -1,2 +1,5 @@ {% load i18n %} -{% blocktrans %}The social account has been disconnected.{% endblocktrans %} + +{% blocktrans %} +The social account has been disconnected. +{% endblocktrans %} From 929ec6bfad74ecf29b7d15c9e4ec067deee52b8b Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 17:08:58 +0100 Subject: [PATCH 26/29] Docstrings added and single line comments removed where necessary to ensure industry best practice --- accounts/admin.py | 6 +++++- accounts/forms.py | 13 ++++++++----- accounts/models.py | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/accounts/admin.py b/accounts/admin.py index 5bfc7dbb..e92c54b9 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -4,7 +4,11 @@ class ProfileAdmin(admin.ModelAdmin): - # Defining fields for Admin panel + """ + Profile Model Admin Panel setup. + Returning and displaying the three custom fields from the extended + allauth signup form. + """ fields = ( 'slack_display_name', 'user_type', diff --git a/accounts/forms.py b/accounts/forms.py index 89a1d057..a84dfa48 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -8,10 +8,6 @@ class ExtendedSignupForm(SignupForm): """ Extending default Django allauth Signup Form to include fields to capture: - first name/last name/slack display name/user type/current lms module - - Also, overriding the init method to call the parent class and reset the - autofocus to suit the form updated flow and adding custom - validation logic to suit the additional fields. """ first_name = forms.CharField(max_length=20) last_name = forms.CharField(max_length=20) @@ -24,11 +20,18 @@ class ExtendedSignupForm(SignupForm): ) def __init__(self, *args, **kwargs): + """ + Setting unique attribute of the class instance and calling the parent + class. + Resetting the form autofocus to 'email' as the first displayed field. + """ super().__init__(*args, **kwargs) - # Resetting the form autofocus to 'email' as the first displayed field. self.fields['email'].widget.attrs['autofocus'] = True def custom_signup(self, request, user): + """ + Custom logic to ensure clean data via the form response. + """ user.first_name = self.cleaned_data["first_name"] user.last_name = self.cleaned_data["last_name"] user.slack_display_name = self.cleaned_data["slack_display_name"] diff --git a/accounts/models.py b/accounts/models.py index f1b8683a..d35ba9d2 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -56,6 +56,9 @@ def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) def __str__(self): + """ + Return Class object to string via the user email value + """ return self.user.email From 2b1ff1278c36e12e8b61158f7e1b740db4980349 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 20:43:05 +0100 Subject: [PATCH 27/29] Refactored models.py Profile fields with default='' instead of Null='' --- accounts/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/models.py b/accounts/models.py index d35ba9d2..218ca750 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -26,18 +26,18 @@ class Profile(models.Model): slack_display_name = models.CharField( max_length=80, blank=False, - null='' + default='' ) user_type = models.CharField( max_length=20, blank=False, - null='', + default='', choices=USER_TYPES_CHOICES ) current_lms_module = models.CharField( max_length=35, blank=False, - null='', + default='', choices=LMS_MODULES_CHOICES ) From f4d3e52fdfc99c7a7a574c00788a672b42f3214b Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 20:43:34 +0100 Subject: [PATCH 28/29] Migrations made to suit new Profile models.py changes in field attributes --- .../migrations/0002_auto_20201020_2042.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 accounts/migrations/0002_auto_20201020_2042.py diff --git a/accounts/migrations/0002_auto_20201020_2042.py b/accounts/migrations/0002_auto_20201020_2042.py new file mode 100644 index 00000000..3eceb93e --- /dev/null +++ b/accounts/migrations/0002_auto_20201020_2042.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='current_lms_module', + field=models.CharField(choices=[('', 'Select Learning Stage'), ('programme_preliminaries', 'Programme Preliminaries'), ('programming_paradigms', 'Programming Paradigms'), ('html_fundamentals', 'HTML Fundamentals'), ('css_fundamentals', 'CSS Fundamentals'), ('user_centric_frontend_development', 'User Centric Frontend Development'), ('javascript_fundamentals', 'Javascript Fundamentals'), ('interactive_frontend_development', 'Interactive Frontend Development'), ('python_fundamentals', 'Python Fundamentals'), ('practical_python', 'Practical Python'), ('data_centric_development', 'Data Centric Development'), ('full_stack_frameworks with django', 'Full Stack Frameworks with Django'), ('alumni', 'Alumni'), ('staff', 'Staff')], default='', max_length=35), + ), + migrations.AlterField( + model_name='profile', + name='slack_display_name', + field=models.CharField(default='', max_length=80), + ), + migrations.AlterField( + model_name='profile', + name='user_type', + field=models.CharField(choices=[('', 'Select Post Category'), ('participant', 'Participant'), ('staff', 'Staff'), ('admin', 'Admin')], default='', max_length=20), + ), + ] From 936651330f6a508a367a8733b91acbe85b326681 Mon Sep 17 00:00:00 2001 From: auxfuse Date: Tue, 20 Oct 2020 23:29:22 +0100 Subject: [PATCH 29/29] Added explicit except catch error in the form of KeyError in the Profiles class save function accounts/models.py --- accounts/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/models.py b/accounts/models.py index 218ca750..ac3aad9f 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -48,7 +48,7 @@ def save(self, *args, **kwargs): self.user_type = self.user.user_type self.current_lms_module = self.user.current_lms_module # when saving via admin panel - except: + except KeyError: self.slack_display_name = self.user.profile.slack_display_name self.user_type = self.user.profile.user_type self.current_lms_module = self.user.profile.current_lms_module