Commit 4ec32855 authored by Skia's avatar Skia

Migrate clubs

parent 2e9fa1a2
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('club', '0002_club_home'),
]
operations = [
migrations.AlterField(
model_name='club',
name='name',
field=models.CharField(verbose_name='name', max_length=64),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('club', '0003_auto_20160813_1448'),
]
operations = [
migrations.AlterField(
model_name='membership',
name='description',
field=models.CharField(verbose_name='description', blank=True, max_length=128),
),
]
......@@ -15,7 +15,7 @@ class Club(models.Model):
"""
The Club class, made as a tree to allow nice tidy organization
"""
name = models.CharField(_('name'), max_length=30)
name = models.CharField(_('name'), max_length=64)
parent = models.ForeignKey('Club', related_name='children', null=True, blank=True)
unix_name = models.CharField(_('unix name'), max_length=30, unique=True,
validators=[
......@@ -72,10 +72,10 @@ class Club(models.Model):
def save(self, *args, **kwargs):
with transaction.atomic():
creation = False
if self.id is None:
old = Club.objects.filter(id=self.id).first()
if not old:
creation = True
else:
old = Club.objects.filter(id=self.id).first()
if old.unix_name != self.unix_name:
self._change_unixname(self.unix_name)
super(Club, self).save(*args, **kwargs)
......@@ -148,7 +148,7 @@ class Membership(models.Model):
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])
description = models.CharField(_('description'), max_length=30, null=False, blank=True)
description = models.CharField(_('description'), max_length=128, null=False, blank=True)
def clean(self):
sub = Subscriber.objects.filter(pk=self.user.pk).first()
......
......@@ -16,7 +16,7 @@
<h3>{{ club.name }}</h3>
<p>{{ club.address }}</p>
<ul>
{% for m in club.members.all() %}
{% for m in club.members.filter(end_date=None).all() %}
<li>{{ m }}</li>
{% endfor %}
</ul>
......
......@@ -19,6 +19,9 @@
{% if object.club_account %}
<li>Accouting: <a href="{{ url('accounting:club_details', c_account_id=object.club_account.id) }}">{{ object }}</a></li>
{% endif %}
{% if object.unix_name == settings.SITH_LAUNDERETTE_MANAGER['unix_name'] %}
<li><a href="{{ url('launderette:launderette_list') }}">{% trans %}Launderette{% endtrans %}</a></li>
{% endif %}
</ul>
{% endblock %}
......
......@@ -43,13 +43,13 @@ class Command(BaseCommand):
home_root.save()
club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root)
club_root.save()
main_club = Club(name=settings.SITH_MAIN_CLUB['name'], unix_name=settings.SITH_MAIN_CLUB['unix_name'],
main_club = Club(id=1, name=settings.SITH_MAIN_CLUB['name'], unix_name=settings.SITH_MAIN_CLUB['unix_name'],
address=settings.SITH_MAIN_CLUB['address'])
main_club.save()
bar_club = Club(name=settings.SITH_BAR_MANAGER['name'], unix_name=settings.SITH_BAR_MANAGER['unix_name'],
bar_club = Club(id=2, name=settings.SITH_BAR_MANAGER['name'], unix_name=settings.SITH_BAR_MANAGER['unix_name'],
address=settings.SITH_BAR_MANAGER['address'])
bar_club.save()
launderette_club = Club(name=settings.SITH_LAUNDERETTE_MANAGER['name'],
launderette_club = Club(id=84, name=settings.SITH_LAUNDERETTE_MANAGER['name'],
unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name'],
address=settings.SITH_LAUNDERETTE_MANAGER['address'])
launderette_club.save()
......
This diff is collapsed.
Markdown is supported
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