1 # -*- coding: utf-8 -*-
3 # This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from django.shortcuts import render, redirect
7 from django.contrib.auth import authenticate, login
8 from django.contrib.auth.models import User
9 from django.core.mail import send_mail
10 from .forms import RegistrationForm
11 from catalogue.models import Document
12 from organizations.models import Organization
16 upcoming = Document.objects.filter(deleted=False).filter(publish_log=None)
17 finished = Document.objects.filter(deleted=False).exclude(publish_log=None)
18 organizations = Organization.objects.all()
19 more_upcoming = upcoming.count() > 8
20 more_finished = finished.count() > 8
21 more_organizations = organizations.count() > 8
22 upcoming = upcoming[:8]
23 finished = finished[:8]
24 organizations = organizations[:8]
26 return render(request, 'main.html', {
29 'organizations': organizations,
30 'more_upcoming': more_upcoming,
31 'more_finished': more_finished,
32 'more_organizations': more_organizations,
36 def register(request):
37 if request.method == 'POST':
38 form = RegistrationForm(request.POST, request.FILES)
40 u = User.objects.create(
41 username=form.cleaned_data['email'],
42 first_name=form.cleaned_data['first_name'],
43 last_name=form.cleaned_data['last_name'],
44 email=form.cleaned_data['email']
46 u.set_password(form.cleaned_data['password'])
48 login(request, authenticate(username=form.cleaned_data['email'], password=form.cleaned_data['password']))
50 'Registered at MIL/PEER',
51 '''You have been successfully registered at MIL/PEER with this e-mail address.
56 MIL/PEER team.''', 'milpeer@mdrn.pl', [form.cleaned_data['email']])
59 form = RegistrationForm()
60 return render(request, 'registration.html', {'form': form})