diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 2cf0bbeb..25b21c63 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -44,6 +44,10 @@ class Command(BaseCommand): bar_club = Club(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'], + unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name'], + address=settings.SITH_LAUNDERETTE_MANAGER['address']) + launderette_club.save() for b in settings.SITH_COUNTER_BARS: g = Group(name=b[1]+" admin") g.save() @@ -63,6 +67,12 @@ class Command(BaseCommand): Welcome to the wiki page! """).save() + p = Page(name="launderette") + p.set_lock(root) + p.save() + p.set_lock(root) + PageRev(page=p, title="", author=root, content="").save() + # Here we add a lot of test datas, that are not necessary for the Sith, but that provide a basic development environment if not options['prod']: # Adding user Skia diff --git a/core/views/page.py b/core/views/page.py index fc164047..b8d91bf1 100644 --- a/core/views/page.py +++ b/core/views/page.py @@ -86,7 +86,6 @@ class PageCreateView(CanEditPropMixin, CreateView): def get_context_data(self, **kwargs): context = super(PageCreateView, self).get_context_data(**kwargs) - print(context) context['new_page'] = True return context diff --git a/counter/migrations/0011_counter_sellers.py b/counter/migrations/0011_counter_sellers.py new file mode 100644 index 00000000..bbba821a --- /dev/null +++ b/counter/migrations/0011_counter_sellers.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('subscription', '0002_auto_20160718_1805'), + ('counter', '0010_auto_20160728_1820'), + ] + + operations = [ + migrations.AddField( + model_name='counter', + name='sellers', + field=models.ManyToManyField(verbose_name='sellers', to='subscription.Subscriber', related_name='counters', blank=True), + ), + ] diff --git a/counter/models.py b/counter/models.py index 18196aa4..ad556bd3 100644 --- a/counter/models.py +++ b/counter/models.py @@ -10,6 +10,8 @@ from random import randrange from club.models import Club from accounting.models import CurrencyField from core.models import Group, User +from subscription.models import Subscriber +from subscription.views import get_subscriber class Customer(models.Model): """ @@ -94,6 +96,7 @@ class Counter(models.Model): type = models.CharField(_('subscription type'), max_length=255, choices=[('BAR',_('Bar')), ('OFFICE',_('Office')), ('EBOUTIC',_('Eboutic'))]) + sellers = models.ManyToManyField(Subscriber, verbose_name=_('sellers'), related_name='counters', blank=True) edit_groups = models.ManyToManyField(Group, related_name="editable_counters", blank=True) view_groups = models.ManyToManyField(Group, related_name="viewable_counters", blank=True) barmen_session = {} @@ -102,8 +105,8 @@ class Counter(models.Model): verbose_name = _('counter') def __getattribute__(self, name): - if name == "owner_group": - return Group.objects.filter(name=self.club.unix_name+settings.SITH_BOARD_SUFFIX).first() + if name == "edit_groups": + return Group.objects.filter(name=self.club.unix_name+settings.SITH_BOARD_SUFFIX).all() return object.__getattribute__(self, name) def __str__(self): @@ -114,11 +117,14 @@ class Counter(models.Model): return reverse('eboutic:main') return reverse('counter:details', kwargs={'counter_id': self.id}) - def can_be_edited_by(self, user): + def is_owned_by(self, user): return user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']) def can_be_viewed_by(self, user): - return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) + if self.type == "BAR" or self.type == "EBOUTIC": + return True + sub = get_subscriber(request.user) + return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or sub in self.sellers def add_barman(counter_id, user_id): """ diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index 317a1b36..36e2cb46 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -16,6 +16,10 @@ {% endmacro %} +{% block title %} +{{ counter }} +{% endblock %} + {% block content %}
{% trans %}Enter client code:{% endtrans %}
-