Commit 5969a032 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Merge branch 'master' into feature/for-members-page

parents 4a8359a3 486ceec7
from __future__ import unicode_literals
from django.forms import ModelForm
from .models import Member
class MemberForm(ModelForm):
class Meta:
fields = ['address_street', 'address_street2',
'address_postal_code', 'address_city', 'phone_number',
'emergency_contact', 'emergency_contact_phone_number',
'show_birthday', 'website',
'profile_description', 'nickname',
'display_name_preference', 'photo', 'language',
'receive_optin', 'receive_newsletter']
model = Member
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-28 22:03+0200\n"
"PO-Revision-Date: 2016-08-28 22:05+0200\n"
"POT-Creation-Date: 2016-09-16 21:37+0200\n"
"PO-Revision-Date: 2016-09-16 21:38+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -18,10 +18,26 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.8\n"
#: admin.py:24
#: admin.py:26
msgid "membership type"
msgstr "lidtype"
#: admin.py:49
msgid "Age"
msgstr "Leeftijd"
#: admin.py:54
msgid "≥ 18"
msgstr "≥ 18"
#: admin.py:55
msgid "< 18"
msgstr "< 18"
#: admin.py:56
msgid "Unknown"
msgstr "Onbekend"
#: models.py:54
msgid "Computing Science"
msgstr "Informatica"
......@@ -175,7 +191,15 @@ msgstr "Ontvang opt-in mailings"
msgid "Receive mailings about vacancies and events from Thalia's sponsors."
msgstr "Ontvang mailings over vacatures en evenmenten van Thalia's sponsoren"
#: models.py:266
#: models.py:264
msgid "Receive newsletter"
msgstr "Ontvang nieuwsbrief"
#: models.py:265
msgid "Receive the Thalia Newsletter"
msgstr "Ontvang de Thalia nieuwsbrief"
#: models.py:272
msgid ""
"Yes, I want Thalia to take the membership fees from my bank account through "
"direct debit for each year."
......@@ -183,71 +207,122 @@ msgstr ""
"Ja, ik wil dat Thalia verschuldigde lidmaatschapsgelden elk jaar van mijn "
"bankrekening afschrijft."
#: models.py:269
#: models.py:275
msgid "No, I will pay the contribution myself"
msgstr "Nee, ik zal de contributie zelf betalen"
#: models.py:270
#: models.py:276
msgid "Direct debit"
msgstr "Automatische afschijving"
#: models.py:271
#: models.py:277
msgid "Each year, have Thalia take the membership fees from my bank account"
msgstr ""
"Laat Thalia elk jaar het lidmaatschapsgeld van mijn bankrekening afschrijven"
#: models.py:277
#: models.py:283
msgid "Bank account"
msgstr "Bankrekening"
#: models.py:278
#: models.py:284
msgid "Bank account for direct debit"
msgstr "Bankrekening voor automatische afschrijving"
#: models.py:298
#: models.py:304
msgid "Display name"
msgstr "Weergavenaam"
#: models.py:323
#: models.py:329
msgid "Member"
msgstr "Lid"
#: models.py:324
#: models.py:330
msgid "Supporter"
msgstr "Begunstiger"
#: models.py:325
#: models.py:331
msgid "Honorary Member"
msgstr "Erelid"
#: models.py:330
#: models.py:336
msgid "Membership type"
msgstr "Lidtype"
#: models.py:339
#: models.py:345
msgid "User"
msgstr "Gebruiker"
#: models.py:343
#: models.py:349
msgid "Membership since"
msgstr "Lid sinds"
#: models.py:344
#: models.py:350
msgid "The date the member started holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap is begonnen."
#: models.py:349
#: models.py:355
msgid "Membership until"
msgstr "Lid tot"
#: models.py:350
#: models.py:356
msgid "The date the member stops holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap beëindigd."
#: templates/members/account.html:6 templates/members/edit_profile.html:5
#: templates/members/index.html:6 templates/members/index.html:9
#: templates/members/profile.html:6
msgid "Members"
msgstr "Leden"
msgid "members"
msgstr "leden"
#: templates/members/account.html:9
msgid "Account"
msgstr "Bankrekening"
#: templates/members/account.html:14
#, python-format
msgid "You’re currently logged in as <strong>%(user)s</strong>"
msgstr "U bent momenteel ingelogd als <strong>%(user)s</strong>"
#: templates/members/account.html:19
msgid "show public profile"
msgstr "bekijk publieke profielpagina"
#: templates/members/account.html:20
msgid "Take a look at your own profile."
msgstr "Bekijk je eigen profielpagina."
#: templates/members/account.html:26 templates/members/edit_profile.html:5
#: templates/members/edit_profile.html:8
msgid "edit profile"
msgstr "profiel bewerken"
#: templates/members/account.html:27
msgid "Edit your profile and avatar."
msgstr "Bewerk je profiel en profielafbeelding."
#: templates/members/account.html:33
msgid "change password"
msgstr "wachtwoord wijzigen"
#: templates/members/account.html:34
msgid "Change your accounts' password."
msgstr "Wijzig het wachtwoord van je account."
#: templates/members/account.html:40
msgid "logout"
msgstr "uitloggen"
#: templates/members/account.html:41
msgid "Leave the restricted area of the website."
msgstr "Verlaat het beveiligde gedeelte van de website."
#: templates/members/edit_profile.html:12
msgid "Your profile has been updated successfully."
msgstr "Je profiel is succesvol opgeslagen."
#: templates/members/edit_profile.html:38
msgid "save"
msgstr "opslaan"
#: templates/members/index.html:12
msgid ""
......@@ -299,8 +374,8 @@ msgid "Next"
msgstr "Volgende"
#: templates/members/profile.html:6
msgid "Profile"
msgstr "Profiel"
msgid "profile"
msgstr "profiel"
#: templates/members/profile.html:25
msgid "About"
......
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans 'Account' %}</h1>
<div class="row">
<div class="span6 offset3">
<p class="text-center">{% blocktrans with user=request.user.username %}You’re currently logged in as <strong>{{ user }}</strong>{% endblocktrans %}.</p>
<hr>
<div>
<a href="{% url 'members:profile' %}">{% trans "show public profile"|capfirst %}</a>
<p>{% blocktrans %}Take a look at your own profile.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'members:edit-profile' %}">{% trans "edit profile"|capfirst %}</a>
<p>{% blocktrans %}Edit your profile and avatar.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'password_change' %}">{% trans "change password"|capfirst %}</a>
<p>{% blocktrans %}Change your accounts' password.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'logout' %}">{% trans "logout"|capfirst %}</a>
<p>{% blocktrans %}Leave the restricted area of the website.{% endblocktrans %}</p>
</div>
</div>
</div>
{% endblock %}}
\ No newline at end of file
{% extends "base.html" %}
{% load static i18n fieldtype %}
{% block title %}{% trans "edit profile"|capfirst %} - {% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans "edit profile"|capfirst %}</h1>
{% if saved %}
<div class="alert alert-success">
{% trans "Your profile has been updated successfully." %}
<button class="close" type="button"><span class="alert-icon-close"></span></button>
</div>
{% endif %}
<form method="post" class="form-horizontal span8 offset2">
{% csrf_token %}
{% for field in form %}
<div class="control-group row {% if field.errors %}error{% endif %}">
<label class="control-label" for="{{ field.name }}">{{ field.label_tag }}</label>
<div class="controls">
{{ field }}
{% for error in field.errors %}
<span class="help-block">{{ error|escape }}</span>
{% endfor %}
{% if field.help_text and field|fieldtype != 'CheckboxInput' %}
<span class="help-block">{{ field.help_text|safe }}</span>
{% endif %}
</div>
</div>
{% endfor %}
<input type="submit" value="{% trans 'save'|capfirst %}" class="btn btn-style1 pull-right login" />
</form>
{% endblock %}
\ No newline at end of file
......@@ -3,10 +3,10 @@
{% load static %}
{% load i18n %}
{% block title %}{% trans "Members" %} - {{ block.super }}{% endblock %}
{% block title %}{% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans "Members" %}</h1>
<h1>{% trans "members"|capfirst %}</h1>
<p class="text-center">
{% blocktrans trimmed %}
......
......@@ -3,7 +3,7 @@
{% load static %}
{% load i18n %}
{% block title %}{% trans "Profile" %} - {% trans "Members" %} - {{ block.super }}{% endblock %}
{% block title %}{% trans "profile"|capfirst %} - {% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>
......
from django import template
register = template.Library()
@register.filter(name='fieldtype')
def fieldtype(field):
return field.field.widget.__class__.__name__
......@@ -6,5 +6,8 @@ from . import views
urlpatterns = [
url('^become-a-member-document/(?P<pk>[0-9]*)', views.get_become_a_member_document, name='become-a-member-document'),
url('^profile/(?P<pk>[0-9]*)$', views.profile, name='profile'),
url('^profile$', views.profile, name='profile'),
url('^profile/edit/$', views.edit_profile, name='edit-profile'),
url('^account$', views.account, name='account'),
url('^$', views.index, name='index'),
]
......@@ -3,11 +3,13 @@ from datetime import date
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import get_object_or_404, render
from django.contrib.auth.decorators import login_required
from django.utils.text import slugify
from sendfile import sendfile
from .models import BecomeAMemberDocument
from .models import Member
from .forms import MemberForm
def index(request):
......@@ -85,8 +87,12 @@ def index(request):
'keywords': keywords})
def profile(request, pk):
member = get_object_or_404(Member, pk=int(pk))
@login_required
def profile(request, pk=None):
if pk:
member = get_object_or_404(Member, pk=int(pk))
else:
member = get_object_or_404(Member, user=request.user)
# Group the memberships under the committees for easier template rendering
memberships = member.committeemembership_set.all()
......@@ -110,7 +116,7 @@ def profile(request, pk):
}
achievements[name]['periods'].sort(key=lambda period: period['since'])
mentor_years = member.mentor_set.all()
mentor_years = member.mentorship_set.all()
for mentor_year in mentor_years:
name = str(mentor_year)
if not achievements.get(name):
......@@ -122,6 +128,28 @@ def profile(request, pk):
{'member': member, 'achievements': achievements.values()})
@login_required
def account(request):
return render(request, 'members/account.html')
@login_required
def edit_profile(request):
member = get_object_or_404(Member, user=request.user)
saved = False
if request.POST:
form = MemberForm(request.POST, instance=member)
if form.is_valid():
saved = True
member = form.save()
form = MemberForm(instance=member)
return render(request, 'members/edit_profile.html',
{'form': form, 'saved': saved})
def become_a_member(request):
context = {'documents': BecomeAMemberDocument.objects.all()}
return render(request, 'singlepages/become_a_member.html', context)
......
from django.contrib import admin
from utils.translation import TranslatedModelAdmin
from .models import MerchandiseItem
admin.site.register(MerchandiseItem)
@admin.register(MerchandiseItem)
class MerchandiseItemAdmin(TranslatedModelAdmin):
fields = ('name', 'price',
'description', 'image',)
from django.core.files.base import ContentFile
from django.core.management.base import BaseCommand
from decimal import Decimal
from merchandise.models import MerchandiseItem
from bs4 import BeautifulSoup
import requests
import os
def filefield_from_url(filefield, url):
file = ContentFile(requests.get(url).content)
filefield.save(os.path.basename(url), file)
class Command(BaseCommand):
help = "Scrapes the merchandise from the old Thalia website"
def handle(self, *args, **options):
input_val = input(
"Do you want to delete all existing objects? (type yes or no) ")
if input_val == 'yes':
MerchandiseItem.objects.all().delete()
session = requests.Session()
url = "https://thalia.nu/index.php/association/merchandise"
src = session.get(url).text
soup = BeautifulSoup(src, 'lxml')
for item in soup.find_all("div", {"class": "post", "id": "item"}):
image_url = item.find("img")['src'].replace('/small', '/large')
title = item.find("h1", {"id": "merchandise-title"}).text
desc = item.find("p", {"id": "merchandise-desc"}).text
price = Decimal(item.find("div", {"id": "merchandise-price"})
.text[9:].replace(',', '.'))
print("Importing {}".format(title))
merch = MerchandiseItem()
merch.name_nl = title
merch.name_en = title
merch.description_nl = desc
merch.description_en = desc
merch.price = price
filefield_from_url(merch.image, image_url)
merch.save()
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-09-16 09:50
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('merchandise', '0002_auto_20160805_1730'),
]
operations = [
migrations.RemoveField(
model_name='merchandiseitem',
name='description',
),
migrations.RemoveField(
model_name='merchandiseitem',
name='name',
),
migrations.AddField(
model_name='merchandiseitem',
name='description_en',
field=models.TextField(default='', verbose_name='description (EN)'),
preserve_default=False,
),
migrations.AddField(
model_name='merchandiseitem',
name='description_nl',
field=models.TextField(default='', verbose_name='description (NL)'),
preserve_default=False,
),
migrations.AddField(
model_name='merchandiseitem',
name='name_en',
field=models.CharField(default='', max_length=200, verbose_name='name (EN)'),
preserve_default=False,
),
migrations.AddField(
model_name='merchandiseitem',
name='name_nl',
field=models.CharField(default='', max_length=200, verbose_name='name (NL)'),
preserve_default=False,
),
]
from django.db import models
from utils.translation import MultilingualField, ModelTranslateMeta
class MerchandiseItem(models.Model):
name = models.CharField(max_length=200)
class MerchandiseItem(models.Model, metaclass=ModelTranslateMeta):
name = MultilingualField(models.CharField, max_length=200)
price = models.DecimalField(max_digits=5, decimal_places=2)
description = models.TextField()
description = MultilingualField(models.TextField)
image = models.ImageField(upload_to='public/merchandise')
def __str__(self):
......
......@@ -3,7 +3,9 @@
{% load i18n %}
{% block body %}
<h1>{% trans "Merchandise" %}</h1><p>{% trans "Below you can find all the merchandise Thalia has available. During every lunch break, the merchandise is for sale in the board room (HG00.150). Outside those hours, please make an appointment or approach the board over drinks." %}</p
<h1>{% trans "Merchandise" %}</h1>
<p class="text-center">{% trans "Below you can find all the merchandise Thalia has available. During every lunch break, the merchandise is for sale in the board room (HG00.150). Outside those hours, please make an appointment or approach the board over drinks." %}</p
{% for item in items %}
......@@ -17,7 +19,7 @@
<div class="span9" id="merchandise-text">
<h1 id="merchandise-title">{{ item.name }}</h1>
<p id="merchandise-desc">{{ item.description }}</p>
<div id="merchandise-price">{% blocktrans %}Price: € {{ item.price }}{% endblocktrans %}</div>
<div id="merchandise-price">{% blocktrans with price=item.price %}Price: € {{ price }}{% endblocktrans %}</div>
</div>
</div>
</div>
......
......@@ -25,14 +25,14 @@
{% if album.shareable %}
data-download="{% url 'photos:shared-download' album.slug album.access_token photo %}" href="{% shared_thumbnail album.slug album.access_token photo '1024x768' fit=False %}"
{% else %}
data-download="{% url 'photos:download' photo %}" href="{% thumbnail photo '1024x768' fit=False %}"
data-download="{% url 'photos:download' photo %}" href="{% thumbnail photo.file '1024x768' fit=False %}"
{% endif %}>
<span class="post-inner">
<span class="inner-img">
{% if album.shareable %}
<img class="rotate{{ photo.rotation }}" src="{% shared_thumbnail album.slug album.access_token photo '220x220' %}" alt="" />
{% else %}
<img class="rotate{{ photo.rotation }}" src="{% thumbnail photo '220x220' %}" alt="" />
<img class="rotate{{ photo.rotation }}" src="{% thumbnail photo.file '220x220' %}" alt="" />
{% endif %}
</span>
<span class="post-overlay">
......
This diff was suppressed by a .gitattributes entry.
......@@ -8,8 +8,10 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-16 21:29+0200\n"
"PO-Revision-Date: 2016-09-16 21:30+0200\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"PO-Revision-Date: 2016-09-21 11:08+0200\n"
"POT-Creation-Date: 2016-09-16 21:34+0200\n"
"PO-Revision-Date: 2016-09-16 21:34+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
......@@ -179,6 +181,40 @@ msgstr "Fout"
msgid "An error occurred."
msgstr "Er is een fout opgetreden."
#: templates/singlepages/association.html:5
msgid ""
"Thalia, the study association of Computer Science and Information Science"
msgstr "Thalia, de studievereniging voor Informatica en Informatiekunde"
#: templates/singlepages/association.html:7
msgid ""
"Thalia is the study association for the Computer Science and Information "
"Science students at Radboud University in Nijmegen. Thalia provides you the "
"necessary distractions during your studies, as we've been doing for the past "
"25 years. And via Thalia students can easily connect with teachers and "
"students from other years."
msgstr ""
"Thalia is de studievereniging voor Informatica en Informatiekunde studenten "
"van de Radboud Universiteit te Nijmegen. Ondertussen 25 jaar oud, zorgt "
"Thalia vooral voor de nodige ontspanning tijdens de studie. Via Thalia "
"kunnen studenten gemakkelijk contacten onderhouden met docenten en studenten "
"van andere jaren."
#: templates/singlepages/association.html:9
msgid ""
"Do you want to do something for Thalia? The association can't exist without "
"active members. The things you can do to help the association are very "
"diverse. It doesn't require a lot of effort and provides a great way to "
"connect! Interested? Don't be shy and send Thalia an <a href=\"mailto:"
"info@thalia.nu\">email</a>."
msgstr ""
"Ook actief worden binnen Thalia? Thalia kan natuurlijk niet bestaan zonder "
"actieve leden. Er zijn een hoop verschillende dingen die je kunt doen om "
"jouw vereniging te helpen. Het kost je vaak weinig moeite en levert een hoop "
"op! Dus heb je interesse in één of meer van de volgende zaken, schroom "
"vooral niet om te reageren en mail <a href=\"mailto:info@thalia.nu"
"\">Thalia<a/>!"
#: templates/singlepages/become_a_member.html:7
msgid ""
"Thalia is the study association for Computing Science and Information "
......
......@@ -2,7 +2,7 @@ from django.utils.translation import ugettext_lazy as _