mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-24 18:14:22 +00:00
Small club update
This commit is contained in:
parent
2f2d5292de
commit
17b4e24aaa
20
club/migrations/0006_auto_20161229_0040.py
Normal file
20
club/migrations/0006_auto_20161229_0040.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0005_auto_20161120_1149'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='membership',
|
||||
name='start_date',
|
||||
field=models.DateField(verbose_name='start date', default=django.utils.timezone.now),
|
||||
),
|
||||
]
|
@ -143,7 +143,7 @@ class Membership(models.Model):
|
||||
"""
|
||||
user = models.ForeignKey(User, verbose_name=_('user'), related_name="memberships", null=False, blank=False)
|
||||
club = models.ForeignKey(Club, verbose_name=_('club'), related_name="members", null=False, blank=False)
|
||||
start_date = models.DateField(_('start date'))
|
||||
start_date = models.DateField(_('start date'), default=timezone.now)
|
||||
end_date = models.DateField(_('end date'), null=True, blank=True)
|
||||
role = models.IntegerField(_('role'), choices=sorted(settings.SITH_CLUB_ROLES.items()),
|
||||
default=sorted(settings.SITH_CLUB_ROLES.items())[0][0])
|
||||
@ -156,11 +156,6 @@ class Membership(models.Model):
|
||||
if Membership.objects.filter(user=self.user).filter(club=self.club).filter(end_date=None).exists():
|
||||
raise ValidationError(_('User is already member of that club'))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.id:
|
||||
self.start_date = timezone.now()
|
||||
return super(Membership, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.club.name+' - '+self.user.username+' - '+str(settings.SITH_CLUB_ROLES[self.role])+str(
|
||||
" - "+str(_('past member')) if self.end_date is not None else ""
|
||||
|
@ -99,7 +99,10 @@ class ClubMemberForm(forms.ModelForm):
|
||||
required_css_class = 'required'
|
||||
class Meta:
|
||||
model = Membership
|
||||
fields = ['user', 'role', 'description']
|
||||
fields = ['user', 'role', 'start_date', 'description']
|
||||
widgets = {
|
||||
'start_date': SelectDate
|
||||
}
|
||||
user = AutoCompleteSelectField('users', required=True, label=_("Select user"), help_text=None)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user