From dc7a649e783546c8e8a47bc004be3799b1b60d1a Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 24 Jul 2023 15:19:56 -0500 Subject: notes: rearranged some things, added registration templates --- .gitignore | 12 ++++++- app/notes/views.py | 11 +++++++ app/posts/views.py | 3 ++ config/base_urls.py | 4 +++ templates/base.html | 7 +++- .../django_registration/activation_complete.html | 7 ++++ .../django_registration/activation_email_body.txt | 5 +++ .../activation_email_subject.txt | 1 + templates/django_registration/logged_out.html | 9 +++++ .../django_registration/registration_complete.html | 7 ++++ .../django_registration/registration_form.html | 24 ++++++++++++++ templates/registration/login.html | 38 ++++++++++++++++++++++ 12 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 templates/django_registration/activation_complete.html create mode 100644 templates/django_registration/activation_email_body.txt create mode 100644 templates/django_registration/activation_email_subject.txt create mode 100644 templates/django_registration/logged_out.html create mode 100644 templates/django_registration/registration_complete.html create mode 100644 templates/django_registration/registration_form.html create mode 100644 templates/registration/login.html diff --git a/.gitignore b/.gitignore index fd7c197..2cc603e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,14 @@ venv/ /static/ /*.json *.log -pdelectronicsdata.csv +csv/ +media +.bash_history +.bash_profile +.cache/ +.ipython/ +.mozilla/ +.pki/ +.wdm/ +wget-hsts +bin/ diff --git a/app/notes/views.py b/app/notes/views.py index 86ad574..7c8f6d8 100644 --- a/app/notes/views.py +++ b/app/notes/views.py @@ -20,6 +20,9 @@ class NoteCreateView(CreateView): def get_success_url(self): return reverse('posts:detail', kwargs={"pk": self.object.post.pk}) + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super(NoteCreateView, self).dispatch(*args, **kwargs) class NoteUpdateView(UpdateView): model = Note @@ -33,6 +36,9 @@ class NoteUpdateView(UpdateView): def get_success_url(self): return reverse('posts:detail', kwargs={"pk": self.object.post.pk}) + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super(NoteUpdateView, self).dispatch(*args, **kwargs) class NoteListView(ListView): model = Note @@ -47,3 +53,8 @@ class NoteListView(ListView): qs = Note.objects.filter(user=self.request.user).filter(status=status_reverse[status]) qs = Note.objects.filter(user=self.request.user) return qs + + + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super(NoteListView, self).dispatch(*args, **kwargs) diff --git a/app/posts/views.py b/app/posts/views.py index 3c25483..3d01ad7 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -21,6 +21,9 @@ class PostListView(ListView): class PostNotesView(DetailView): model = Post + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super(PostNotesView, self).dispatch(*args, **kwargs) ''' class UpdateViewWithUser(UpdateView): diff --git a/config/base_urls.py b/config/base_urls.py index 9f7f890..a3e8dc9 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -13,6 +13,10 @@ AdminSite.site_header = "PD Data Sorting Tools" AdminSite.site_title = "Sorting" urlpatterns = [ path(r'admin/', admin.site.urls), + path(r'accounts/', include('django_registration.backends.activation.urls')), + path(r'accounts/', include('django.contrib.auth.urls')), + path(r'', include('django_registration.backends.activation.urls')), + path(r'', include('django.contrib.auth.urls')), path(r'code/', include('deals.urls', namespace='deals')), path(r'post/', include('posts.urls')), re_path(r'^post/$', RedirectView.as_view(url='/posts/')), diff --git a/templates/base.html b/templates/base.html index c771084..e248573 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,9 +20,14 @@ Wired Guide Tool {% block breadcrumbs %}{% endblock %} diff --git a/templates/django_registration/activation_complete.html b/templates/django_registration/activation_complete.html new file mode 100644 index 0000000..d83317a --- /dev/null +++ b/templates/django_registration/activation_complete.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} +
+

Your account is now active.

+

Login and get started!

+
+{% endblock %} diff --git a/templates/django_registration/activation_email_body.txt b/templates/django_registration/activation_email_body.txt new file mode 100644 index 0000000..8b1e134 --- /dev/null +++ b/templates/django_registration/activation_email_body.txt @@ -0,0 +1,5 @@ +Thanks for signing up with {{site}}, just one more thing to do, click this link to confirm your email: + +{{scheme}}://{{site}}/register/{{activation_key}} + + diff --git a/templates/django_registration/activation_email_subject.txt b/templates/django_registration/activation_email_subject.txt new file mode 100644 index 0000000..ea275d2 --- /dev/null +++ b/templates/django_registration/activation_email_subject.txt @@ -0,0 +1 @@ +Please Activate Your Account diff --git a/templates/django_registration/logged_out.html b/templates/django_registration/logged_out.html new file mode 100644 index 0000000..cccb58b --- /dev/null +++ b/templates/django_registration/logged_out.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block title %}Logged Out{% endblock %} + +{% block primary %} +

You're logged out

+

Thanks for visiting the site today

+Login again +{% endblock %} diff --git a/templates/django_registration/registration_complete.html b/templates/django_registration/registration_complete.html new file mode 100644 index 0000000..59677ce --- /dev/null +++ b/templates/django_registration/registration_complete.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} +
+

Thanks for signing up.

+

Please check your email for a link to confirm you new account. +

+{% endblock %} diff --git a/templates/django_registration/registration_form.html b/templates/django_registration/registration_form.html new file mode 100644 index 0000000..8573918 --- /dev/null +++ b/templates/django_registration/registration_form.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} +{% block content %} +
+{% csrf_token %} +{{ form.non_field_errors }} +{% for field in form %} +
+{{field.label_tag}} +{{field}} +{% if field.label == "Password" %}Password should be 8 or more characters.{% endif %} +{% if field.errors %}{{field.errors}}{% endif %} +
+{% endfor %} +

+
+

Already have an account? Log in.

+{% endblock %} +{% block extra %} + +{{site.name}} +{%endblock%} diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..a7e7978 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} +{% block primary %} +
+
+Login to {{site.name}} +{% if form.errors %} +

Your username and password didn't match. Please try again.

+{% endif %} + +{% if next %} + {% if user.is_authenticated %} +

Your account doesn't have access to this page. To proceed, + please login with an account that has access.

+ {% else %} +

Please login to see this page.

+ {% endif %} +{% endif %} + +{% csrf_token %} +
+ {{ form.username.label_tag }} + {{ form.username }} +
+
+ {{ form.password.label_tag }} + {{ form.password }} +
+ + + +
+ +{# Assumes you setup the password_reset view in your URLconf #} +
+ +Forgot your password?

+
+{% endblock %} -- cgit v1.2.3-70-g09d2