Skip to content

Commit

Permalink
💚 🐛 Fixes various small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jip J. Dekker committed Apr 4, 2017
1 parent 4d6bab3 commit 1ed7f7b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion website/members/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date, datetime
from datetime import datetime

from django import forms
from django.contrib.auth import forms as auth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-04 11:43
# Generated by Django 1.10.6 on 2017-04-04 12:32
from __future__ import unicode_literals

import django.core.validators
Expand Down Expand Up @@ -37,6 +37,11 @@ class Migration(migrations.Migration):
field=models.CharField(blank=True, default='', help_text='Enter the year you started studying at the TakNat faculty', max_length=4, validators=[django.core.validators.RegexValidator(message='Please enter a valid year', regex='^\\d{4}$')], verbose_name='Registration year'),
preserve_default=False,
),
migrations.AlterField(
model_name='member',
name='study',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='members.StudyProgram', verbose_name='Study program'),
),
migrations.AlterField(
model_name='section',
name='abbreviation',
Expand Down
8 changes: 3 additions & 5 deletions website/members/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from django.forms import CheckboxSelectMultiple
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from modelcluster.models import ClusterableModel
from requests.auth import HTTPDigestAuth
from simple_email_confirmation.models import SimpleEmailConfirmationUserMixin
from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList, \
FieldPanel
from wagtail.wagtailcore.models import Orderable

from utils.translation import TranslatedField

Expand Down Expand Up @@ -72,12 +70,12 @@ class Meta:

def __str__(self) -> str:
if self.degree:
return _('%(degree_type)s in %(study_program)') % {
return _('%(degree_type)s in %(study_program)s') % {
'degree_type': self.degree,
'study_program': self.name,
}
else:
return self.name
return self.name.__str__()

# ------ Administrator settings ------
edit_handler = TabbedInterface([
Expand Down Expand Up @@ -137,7 +135,7 @@ def __str__(self) -> str:
if self.abbreviation:
return '%s - %s' % (self.abbreviation, self.name)
else:
return self.name
return self.name.__str__()

# ------ Administrator settings ------
edit_handler = TabbedInterface([
Expand Down
10 changes: 8 additions & 2 deletions website/members/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def setUp(self):
self.study = StudyProgram.objects.create(
name_en='Chemistry',
name_sv='Kemi',
degree='bachelor',
degree='bsc',
)
self.member = Member.objects.create(
username='moore',
Expand Down Expand Up @@ -132,12 +132,15 @@ def test_change_study(self):
new_study = StudyProgram.objects.create(
name_en='Superhero',
name_sv='Superhjälte',
degree='master',
degree='msc',
)
data = {
'study': new_study.id.__str__(),
'registration_year': '1980',
# required fields
'person_number': self.member.person_number(),
'first_name': self.member.first_name,
'last_name': self.member.last_name,
}
response = self.client.post(reverse('profile'), data)

Expand All @@ -154,7 +157,10 @@ def test_change_email(self):
new_email = 'f.gordon@localhost'
data = {
'email': 'f.gordon@localhost',
# required fields
'person_number': self.member.person_number(),
'first_name': self.member.first_name,
'last_name': self.member.last_name,
}
response = self.client.post(reverse('profile'), data)

Expand Down
1 change: 1 addition & 0 deletions website/members/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ class EducationAdminGroup(ModelAdminGroup):
menu_order = 450
items = (StudyProgramAdmin, SectionAdmin)


modeladmin_register(EducationAdminGroup)

0 comments on commit 1ed7f7b

Please sign in to comment.