diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-24 15:19:56 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-24 15:19:56 -0500 |
commit | dc7a649e783546c8e8a47bc004be3799b1b60d1a (patch) | |
tree | 9fc591eea6fcc9bfe62746bb08310510e1200fa2 | |
parent | d5c3fdc2be4cf7e19102218aea980ff2f52fc02b (diff) |
notes: rearranged some things, added registration templates
-rw-r--r-- | .gitignore | 12 | ||||
-rw-r--r-- | app/notes/views.py | 11 | ||||
-rw-r--r-- | app/posts/views.py | 3 | ||||
-rw-r--r-- | config/base_urls.py | 4 | ||||
-rw-r--r-- | templates/base.html | 7 | ||||
-rw-r--r-- | templates/django_registration/activation_complete.html | 7 | ||||
-rw-r--r-- | templates/django_registration/activation_email_body.txt | 5 | ||||
-rw-r--r-- | templates/django_registration/activation_email_subject.txt | 1 | ||||
-rw-r--r-- | templates/django_registration/logged_out.html | 9 | ||||
-rw-r--r-- | templates/django_registration/registration_complete.html | 7 | ||||
-rw-r--r-- | templates/django_registration/registration_form.html | 24 | ||||
-rw-r--r-- | templates/registration/login.html | 38 |
12 files changed, 126 insertions, 2 deletions
@@ -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 @@ <a class="logo-link" href="/" title="Home">Wired Guide Tool</span></a> </div> <nav> - <a class="nav-item" href="/posts" title="View Guides">Guides</a> <a class="nav-item" href="/notes/todo" title="See what needs to be called in">Todo</a> <a class="nav-item" href="/notes" title="View Guides">Notes</a> + <a class="nav-item" href="/posts" title="View Guides">Guides</a> + <span class="nav-item" > + <form class="inline btn" action="/logout/" method="post">{% csrf_token %} + <button type="submit" value="Log out" class="btn-link">Log out</button> + </form> + </span> </nav> </header> {% 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 %} +<main class="single-col"> +<h1>Your account is now active.</h1> +<p><a href="{% url 'login' %}">Login</a> and get started!</p> +</main> +{% 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: + +<a href="{{scheme}}://{{site}}/activate/{{activation_key}}">{{scheme}}://{{site}}/register/{{activation_key}}</a> + + 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 %} +<h2>You're logged out</h2> +<h4>Thanks for visiting the site today</h4> +<a href="{%url 'login'%}">Login again</a> +{% 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 %} +<main class="single-col"> +<h1>Thanks for signing up.</h1> +<p>Please check your email for a link to confirm you new account.<?p> +</main> +{% 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 %} +<form action="" method="post"> +{% csrf_token %} +{{ form.non_field_errors }} +{% for field in form %} +<fieldset {% if field.errors %}class="error"{%endif%}> +{{field.label_tag}} +{{field}} +{% if field.label == "Password" %}<span class="helptext">Password should be 8 or more characters.</span>{% endif %} +{% if field.errors %}{{field.errors}}{% endif %} +</fieldset> +{% endfor %} +<p><input class="btn" value="submit" type="submit" /></p> +</form> +<p class="text-muted">Already have an account? <a href="{% url 'login' %}">Log in</a>.</p> +{% endblock %} +{% block extra %} +<div class="overlay-content" id="js-overlay-content" style="display: none;"> + {% include 'lib/login.html' with form=login_form site=site %} + {{login_form}} +</div> +{{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 %} +<main class="narrow"> +<form class="form-narrow" method="post" action="{% url 'login' %}"> +<legend class="fancy-legend">Login to {{site.name}}</legend> +{% if form.errors %} +<p>Your username and password didn't match. Please try again.</p> +{% endif %} + +{% if next %} + {% if user.is_authenticated %} + <p>Your account doesn't have access to this page. To proceed, + please login with an account that has access.</p> + {% else %} + <p>Please login to see this page.</p> + {% endif %} +{% endif %} + +{% csrf_token %} +<fieldset> + {{ form.username.label_tag }} + {{ form.username }} +</fieldset> +<fieldset> + {{ form.password.label_tag }} + {{ form.password }} +</fieldset> + +<input type="submit" class="btn sm" value="login"> +<input type="hidden" name="next" value="{{ next }}"> +</form> + +{# Assumes you setup the password_reset view in your URLconf #} +<hr /> +<!--comment <p class="text-center">No account yet? <a href="/register/">Sign up</a>.<br>--> +<a href="{% url 'password_reset' %}">Forgot your password?</a></p> +</main> +{% endblock %} |