Commit 0191629a authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'feature/68-mentor-on-profile' into 'master'

Mentor achievement on profile (and fixes)

Closes #68.

!61 did not have a admin page for the mentor model.
The __str__ gave an error and the model name was plural instead of singular.

And: the mentorship is now shown on the members' profile pages.

See merge request !62
parents 8ad68bee a2ebd31a
......@@ -20,3 +20,8 @@ class BoardAdmin(admin.ModelAdmin):
@admin.register(models.CommitteeMembership)
class CommitteeMembershipAdmin(admin.ModelAdmin):
pass
@admin.register(models.Mentorship)
class MentorsAdmin(admin.ModelAdmin):
pass
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-09-06 08:15
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('committees', '0007_mentors'),
]
operations = [
migrations.RenameModel(
old_name='Mentors',
new_name='Mentorship',
),
]
......@@ -248,9 +248,9 @@ class CommitteeMembership(models.Model):
verbose_name_plural = _('committee memberships')
class Mentors(models.Model):
class Mentorship(models.Model):
members = models.ManyToManyField(Member)
year = models.IntegerField(unique=True)
def __str__(self):
return _("Mentor introduction {year}".format(self.year))
return _("Mentor introduction {year}").format(year=self.year)
......@@ -109,6 +109,14 @@ def profile(request, pk):
}
achievements[name]['periods'].sort(key=lambda period: period['since'])
mentor_years = member.mentor_set.all()
for mentor_year in mentor_years:
name = str(mentor_year)
if not achievements.get(name):
achievements[name] = {
'name': name
}
return render(request, 'members/profile.html',
{'member': member, 'achievements': achievements.values()})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment