|
7 | 7 | from django_filters import FilterSet
|
8 | 8 | from django_filters.views import FilterView
|
9 | 9 | from django.http import HttpResponse, HttpResponseRedirect
|
10 |
| -from django.shortcuts import render |
| 10 | +from django.shortcuts import render, redirect |
11 | 11 | from django.urls import reverse
|
12 | 12 | from django.utils.html import format_html
|
13 | 13 | from django_tables2 import SingleTableView, SingleTableMixin
|
14 | 14 |
|
15 |
| -from ponder.forms import CategorizationForm, CategorizerForm |
| 15 | +from ponder.forms import CategorizationForm, CategorizerForm, UserRegistrationForm |
16 | 16 | from .models import Categorization, User, BugFix, Categorizer, CommitDetail, Commit, ProblemCategory, ProblemCause, \
|
17 | 17 | ProblemFix, ProblemSymptom
|
18 | 18 | from .tables import Categorizations_FilterTable, BugFixes_FilterTable, BugFixesTable, CommitDetailsTable, CommitsTable
|
@@ -41,6 +41,19 @@ def index(request):
|
41 | 41 | context = {'projects': parts, 'groups': groups}
|
42 | 42 | return render(request, 'ponder/index.html', context)
|
43 | 43 |
|
| 44 | +def register(request): |
| 45 | + if request.method == 'POST': |
| 46 | + form = UserRegistrationForm(request.POST) |
| 47 | + if form.is_valid(): |
| 48 | + new_user = form.save(commit=False) |
| 49 | + new_user.set_password(form.cleaned_data['password']) |
| 50 | + new_user.save() |
| 51 | + login(request, new_user) |
| 52 | + return redirect('index') |
| 53 | + else: |
| 54 | + form = UserRegistrationForm() |
| 55 | + return render(request, 'ponder/register.html', {'form': form}) |
| 56 | + |
44 | 57 | @login_required
|
45 | 58 | def special(request):
|
46 | 59 | return HttpResponse("You are logged in")
|
|
0 commit comments