Some classes defined twice -- correction

This commit is contained in:
guillaume-renaud 2017-01-03 16:29:13 +01:00
parent 8f88f7cb70
commit fa97929da8

View File

@ -22,8 +22,8 @@ class StockItemList(CounterAdminTabsMixin, CanCreateMixin, ListView):
pk_url_kwarg = "stock_id" pk_url_kwarg = "stock_id"
current_tab = "stocks" current_tab = "stocks"
#def can_be_viewed_by(self, user): def can_be_viewed_by(self, user):
#return user.is_in_group(settings.SITH_GROUPS['counter-admin'].id) return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView): class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
""" """
@ -33,6 +33,9 @@ class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
template_name = 'stock/stock_list.jinja' template_name = 'stock/stock_list.jinja'
current_tab = "stocks" current_tab = "stocks"
def can_be_viewed_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
class StockEditForm(forms.ModelForm): class StockEditForm(forms.ModelForm):
""" """
@ -64,39 +67,8 @@ class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first() context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
return context return context
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView): def can_be_viewed_by(self, user):
""" return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
A list view for the admins
"""
model = Stock
template_name = 'stock/stock_list.jinja'
current_tab = "stocks"
class StockEditForm(forms.ModelForm):
"""
A form to change stock's characteristics
"""
class Meta:
model = Stock
fields = ['name', 'counter']
def __init__(self, *args, **kwargs):
super(StockEditForm, self).__init__(*args, **kwargs)
def save(self, *args, **kwargs):
return super(StockEditForm, self).save(*args, **kwargs)
class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
"""
An edit view for the stock
"""
model = Stock
form_class = StockEditForm
pk_url_kwarg = "stock_id"
template_name = 'core/edit.jinja'
current_tab = "stocks"
class StockItemEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView): class StockItemEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):