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 honeypot.decorators import check_honeypot
12 from .forms import RegistrationForm
13 from catalogue.models import Document
14 from organizations.models import Organization
18 upcoming = Document.objects.filter(deleted=False).filter(publish_log=None)
19 finished = Document.objects.filter(deleted=False).exclude(publish_log=None)
20 organizations = Organization.objects.all()
21 more_upcoming = upcoming.count() > 8
22 more_finished = finished.count() > 8
23 more_organizations = organizations.count() > 8
24 upcoming = upcoming[:8]
25 finished = finished[:8]
26 organizations = organizations[:8]
28 return render(request, 'main.html', {
31 'organizations': organizations,
32 'more_upcoming': more_upcoming,
33 'more_finished': more_finished,
34 'more_organizations': more_organizations,
39 def register(request):
40 if request.method == 'POST':
41 form = RegistrationForm(request.POST, request.FILES)
43 u = User.objects.create(
44 username=form.cleaned_data['email'],
45 first_name=form.cleaned_data['first_name'],
46 last_name=form.cleaned_data['last_name'],
47 email=form.cleaned_data['email']
49 u.set_password(form.cleaned_data['password'])
51 login(request, authenticate(username=form.cleaned_data['email'], password=form.cleaned_data['password']))
53 'Registered at MIL/PEER',
54 '''You have been successfully registered at MIL/PEER with this e-mail address.
59 MIL/PEER team.''', 'milpeer@mdrn.pl', [form.cleaned_data['email']])
62 form = RegistrationForm()
63 return render(request, 'registration.html', {'form': form})