Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.ipynb*
*.sublime-workspace
.directory/*
.DS_Store

*.sqlite3
gcmk
Empty file added accounts/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
name = 'accounts'
Empty file added accounts/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions accounts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path

from . import views


urlpatterns = [
path('signup/', views.SignUp.as_view(), name='signup'),
]
12 changes: 12 additions & 0 deletions accounts/views.py
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions gcmk_library/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'rest_framework',
'rest_framework.authtoken',
'django_filters',
'accounts.apps.AccountsConfig'
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions gcmk_library/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions library/migrations/0006_loan_approved.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
14 changes: 14 additions & 0 deletions library/migrations/0013_merge_20190519_1154.py
Original file line number Diff line number Diff line change
@@ -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 = [
]
17 changes: 17 additions & 0 deletions library/migrations/0014_auto_20190519_1154.py
Original file line number Diff line number Diff line change
@@ -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'},
),
]
1 change: 1 addition & 0 deletions library/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions library/templates/base_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<li><a href="{% url 'logout'%}?next={{request.path}}">Logout</a></li>
{% else %}
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
<li><a href="{% url 'signup'%}?next={{request.path}}">Signup</a></li>
{% endif %}
</ul>
{% if perms.library.can_mark_returned %}
Expand Down
10 changes: 10 additions & 0 deletions templates/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'base_generic.html' %}

{% block content %}
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Sign up</button>
</form>
{% endblock %}