From 49204239596cb5530fa60a30f7864e9242e50423 Mon Sep 17 00:00:00 2001 From: Thiviyan Thanapalasingam Date: Sun, 19 May 2019 11:41:36 +0100 Subject: [PATCH 1/2] Add .DS_Store to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6128e7e..8525966 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .ipynb* *.sublime-workspace .directory/* +.DS_Store *.sqlite3 gcmk From 220216b1f034369a9a433b14b6e7c21fe16d4f46 Mon Sep 17 00:00:00 2001 From: Thiviyan Thanapalasingam Date: Sun, 19 May 2019 13:17:17 +0100 Subject: [PATCH 2/2] New feature: Implement Signup Interface --- accounts/__init__.py | 0 accounts/admin.py | 3 +++ accounts/apps.py | 5 +++++ accounts/migrations/__init__.py | 0 accounts/models.py | 3 +++ accounts/tests.py | 3 +++ accounts/urls.py | 8 ++++++++ accounts/views.py | 12 ++++++++++++ gcmk_library/settings.py | 1 + gcmk_library/urls.py | 1 + library/migrations/0006_loan_approved.py | 18 ++++++++++++++++++ library/migrations/0013_merge_20190519_1154.py | 14 ++++++++++++++ library/migrations/0014_auto_20190519_1154.py | 17 +++++++++++++++++ library/models.py | 1 + library/templates/base_generic.html | 1 + templates/signup.html | 10 ++++++++++ 16 files changed, 97 insertions(+) create mode 100644 accounts/__init__.py create mode 100644 accounts/admin.py create mode 100644 accounts/apps.py create mode 100644 accounts/migrations/__init__.py create mode 100644 accounts/models.py create mode 100644 accounts/tests.py create mode 100644 accounts/urls.py create mode 100644 accounts/views.py create mode 100644 library/migrations/0006_loan_approved.py create mode 100644 library/migrations/0013_merge_20190519_1154.py create mode 100644 library/migrations/0014_auto_20190519_1154.py create mode 100644 templates/signup.html diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..8c38f3f --- /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 0000000..9b3fc5a --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + name = 'accounts' diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..03eb3b8 --- /dev/null +++ b/accounts/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + + +urlpatterns = [ + path('signup/', views.SignUp.as_view(), name='signup'), +] \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..eeb394d --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,12 @@ +from django.shortcuts import render + +# Create your views here. +from django.contrib.auth.forms import UserCreationForm +from django.urls import reverse_lazy +from django.views import generic + + +class SignUp(generic.CreateView): + form_class = UserCreationForm + success_url = reverse_lazy('login') + template_name = 'signup.html' diff --git a/gcmk_library/settings.py b/gcmk_library/settings.py index 8c626b8..cf726fa 100644 --- a/gcmk_library/settings.py +++ b/gcmk_library/settings.py @@ -42,6 +42,7 @@ 'rest_framework', 'rest_framework.authtoken', 'django_filters', + 'accounts.apps.AccountsConfig' ] MIDDLEWARE = [ diff --git a/gcmk_library/urls.py b/gcmk_library/urls.py index 7b43154..7ac0d67 100644 --- a/gcmk_library/urls.py +++ b/gcmk_library/urls.py @@ -24,5 +24,6 @@ path('admin/', admin.site.urls), path('library/', include('library.urls')), path('', RedirectView.as_view(url='/library/', permanent=True)), + path('accounts/', include('accounts.urls')), path('accounts/', include('django.contrib.auth.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/library/migrations/0006_loan_approved.py b/library/migrations/0006_loan_approved.py new file mode 100644 index 0000000..65b20e1 --- /dev/null +++ b/library/migrations/0006_loan_approved.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.1 on 2019-05-19 10:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0005_set_config_values_20190121_1204'), + ] + + operations = [ + migrations.AddField( + model_name='loan', + name='approved', + field=models.BooleanField(default=False), + ), + ] diff --git a/library/migrations/0013_merge_20190519_1154.py b/library/migrations/0013_merge_20190519_1154.py new file mode 100644 index 0000000..d23b7d3 --- /dev/null +++ b/library/migrations/0013_merge_20190519_1154.py @@ -0,0 +1,14 @@ +# Generated by Django 2.2.1 on 2019-05-19 10:54 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0012_auto_20190518_1352'), + ('library', '0006_loan_approved'), + ] + + operations = [ + ] diff --git a/library/migrations/0014_auto_20190519_1154.py b/library/migrations/0014_auto_20190519_1154.py new file mode 100644 index 0000000..47294b0 --- /dev/null +++ b/library/migrations/0014_auto_20190519_1154.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.1 on 2019-05-19 10:54 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0013_merge_20190519_1154'), + ] + + operations = [ + migrations.AlterModelOptions( + name='category', + options={'verbose_name_plural': 'categories'}, + ), + ] diff --git a/library/models.py b/library/models.py index 7e06807..ea41644 100644 --- a/library/models.py +++ b/library/models.py @@ -97,6 +97,7 @@ class Loan(models.Model): borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) loan_start = models.DateField() return_due = models.DateField() + approved = models.BooleanField(default=False) date_returned = models.DateField(null=True, blank=True) microbit_id = models.PositiveIntegerField(blank=True, null=True) last_microbit_update = models.DateTimeField(blank=True, null=True) diff --git a/library/templates/base_generic.html b/library/templates/base_generic.html index 0b4a8fe..5c4403a 100644 --- a/library/templates/base_generic.html +++ b/library/templates/base_generic.html @@ -54,6 +54,7 @@
  • Logout
  • {% else %}
  • Login
  • +
  • Signup
  • {% endif %} {% if perms.library.can_mark_returned %} diff --git a/templates/signup.html b/templates/signup.html new file mode 100644 index 0000000..2d45b76 --- /dev/null +++ b/templates/signup.html @@ -0,0 +1,10 @@ +{% extends 'base_generic.html' %} + +{% block content %} +

    Sign up

    +
    + {% csrf_token %} + {{ form.as_p }} + +
    +{% endblock %} \ No newline at end of file