Nice club presentation

This commit is contained in:
2017-09-19 16:27:48 +02:00
parent 790d723d08
commit db509bf060
6 changed files with 51 additions and 3 deletions

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('club', '0010_auto_20170912_2028'),
]
operations = [
migrations.AddField(
model_name='club',
name='short_description',
field=models.CharField(max_length=1000, verbose_name='short description', blank=True),
),
]

View File

@ -32,6 +32,7 @@ from django.db import transaction
from django.core.urlresolvers import reverse
from django.utils import timezone
from django.core.validators import RegexValidator, validate_email
from django.utils.functional import cached_property
from core.models import User, MetaGroup, Group, SithFile, RealGroup, Notification, Page
@ -59,6 +60,7 @@ class Club(models.Model):
)
logo = models.ImageField(upload_to='club_logos', verbose_name=_('logo'), null=True, blank=True)
is_active = models.BooleanField(_('is active'), default=True)
short_description = models.CharField(_('short description'), max_length=1000, blank=True)
address = models.CharField(_('address'), max_length=254)
# email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically
owner_group = models.ForeignKey(Group, related_name="owned_club",
@ -72,6 +74,10 @@ class Club(models.Model):
class Meta:
ordering = ['name', 'unix_name']
@cached_property
def president(self):
return self.members.filter(role=settings.SITH_CLUB_ROLES_ID['President'], start_date__lte=timezone.now()).first()
def check_loop(self):
"""Raise a validation error when a loop is found within the parent list"""
objs = []

View File

@ -6,7 +6,9 @@
{% macro display_club(club) -%}
<li><a href="{{ url('club:club_view', club_id=club.id) }}">{{ club.name }}</a>
{%- if club.children.all()|length != 0 %}
{% if club.president %} - <a href="{{ url('core:user_profile', user_id=club.president.user.id) }}">{{ club.president.user }}</a>{% endif %}
{% if club.short_description %}<p>{{ club.short_description|markdown }}</p>{% endif %}
{%- if club.children.exclude(is_active=False).all()|length != 0 %}
<ul>
{%- for c in club.children.order_by('name') %}
{{ display_club(c) }}
@ -23,7 +25,7 @@
{% if club_list %}
<h3>{% trans %}Club list{% endtrans %}</h3>
<ul>
{%- for c in club_list.order_by('name') if c.parent is none %}
{%- for c in club_list.exclude(is_active=False).order_by('name') if c.parent is none %}
{{ display_club(c) }}
{%- endfor %}
</ul>

View File

@ -343,7 +343,7 @@ class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
"""
model = Club
pk_url_kwarg = "club_id"
fields = ['address', 'logo']
fields = ['address', 'logo', 'short_description']
template_name = 'core/edit.jinja'
current_tab = "edit"