mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 04:49:25 +00:00
Rename and refactor some settings
This commit is contained in:
@ -1,26 +1,40 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic import ListView, DetailView, RedirectView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.forms.models import modelform_factory
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
||||
from counter.models import Counter
|
||||
# Create your views here.
|
||||
|
||||
class CounterListView(CanViewMixin, ListView):
|
||||
model = Counter
|
||||
template_name = 'counter/counter_list.jinja'
|
||||
|
||||
class CounterDetail(CanViewMixin, DetailView):
|
||||
"""
|
||||
The public (barman) view
|
||||
"""
|
||||
model = Counter
|
||||
template_name = 'counter/counter_detail.jinja'
|
||||
pk_url_kwarg = "counter_id"
|
||||
|
||||
class CounterLogin(RedirectView):
|
||||
permanent = False
|
||||
def post(self): # TODO: finish that
|
||||
print(self.request)
|
||||
form = AuthenticationForm(self.request, data=self.request.POST)
|
||||
if form.is_valid():
|
||||
print("Barman logged")
|
||||
|
||||
class CounterListView(CanViewMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
"""
|
||||
model = Counter
|
||||
template_name = 'counter/counter_list.jinja'
|
||||
|
||||
class CounterEditView(CanEditMixin, UpdateView):
|
||||
"""
|
||||
Edit a Counter's main informations (for the counter's members)
|
||||
Edit a counter's main informations (for the counter's admin)
|
||||
"""
|
||||
model = Counter
|
||||
form_class = modelform_factory(Counter, fields=['name', 'club', 'type', 'products'],
|
||||
@ -30,7 +44,7 @@ class CounterEditView(CanEditMixin, UpdateView):
|
||||
|
||||
class CounterCreateView(CanEditMixin, CreateView):
|
||||
"""
|
||||
Edit a Counter's main informations (for the counter's members)
|
||||
Create a counter (for the admins)
|
||||
"""
|
||||
model = Counter
|
||||
form_class = modelform_factory(Counter, fields=['name', 'club', 'type', 'products'],
|
||||
@ -39,9 +53,11 @@ class CounterCreateView(CanEditMixin, CreateView):
|
||||
|
||||
class CounterDeleteView(CanEditMixin, DeleteView):
|
||||
"""
|
||||
Edit a Counter's main informations (for the counter's members)
|
||||
Delete a counter (for the admins)
|
||||
"""
|
||||
model = Counter
|
||||
pk_url_kwarg = "counter_id"
|
||||
template_name = 'core/delete_confirm.jinja'
|
||||
success_url = reverse_lazy('counter:admin_list')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user