mirror of https://gitlab.crans.org/bde/nk20
Create WEI
This commit is contained in:
parent
69b7f31eed
commit
ea8e25a7b3
|
@ -17,7 +17,7 @@ def save_user_note(instance, raw, **_kwargs):
|
||||||
instance.note.save()
|
instance.note.save()
|
||||||
|
|
||||||
|
|
||||||
def save_club_note(instance, created, raw, **_kwargs):
|
def save_club_note(instance, raw, **_kwargs):
|
||||||
"""
|
"""
|
||||||
Hook to create and save a note when a club is updated
|
Hook to create and save a note when a club is updated
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,6 @@ def save_club_note(instance, created, raw, **_kwargs):
|
||||||
# When provisionning data, do not try to autocreate
|
# When provisionning data, do not try to autocreate
|
||||||
return
|
return
|
||||||
|
|
||||||
if created:
|
from .models import NoteClub
|
||||||
from .models import NoteClub
|
NoteClub.objects.get_or_create(club=instance)
|
||||||
NoteClub.objects.create(club=instance)
|
|
||||||
instance.note.save()
|
instance.note.save()
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import WEIListView, WEIDetailView, WEIUpdateView
|
from .views import WEIListView, WEICreateView, WEIDetailView, WEIUpdateView
|
||||||
|
|
||||||
|
|
||||||
app_name = 'wei'
|
app_name = 'wei'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('list/', WEIListView.as_view(), name="wei_list"),
|
path('list/', WEIListView.as_view(), name="wei_list"),
|
||||||
|
path('create/', WEICreateView.as_view(), name="wei_create"),
|
||||||
path('detail/<int:pk>/', WEIDetailView.as_view(), name="wei_detail"),
|
path('detail/<int:pk>/', WEIDetailView.as_view(), name="wei_detail"),
|
||||||
path('update/<int:pk>/', WEIUpdateView.as_view(), name="wei_update"),
|
path('update/<int:pk>/', WEIUpdateView.as_view(), name="wei_update"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,11 +7,11 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.views.generic import DetailView, UpdateView
|
from django.views.generic import DetailView, UpdateView, CreateView
|
||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
from member.models import Membership
|
from member.models import Membership, Club
|
||||||
from member.tables import MembershipTable
|
from member.tables import MembershipTable
|
||||||
from note.models import Transaction
|
from note.models import Transaction, NoteClub
|
||||||
from note.tables import HistoryTable
|
from note.tables import HistoryTable
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.views import ProtectQuerysetMixin
|
from permission.views import ProtectQuerysetMixin
|
||||||
|
@ -29,6 +29,26 @@ class WEIListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
table_class = WEITable
|
table_class = WEITable
|
||||||
|
|
||||||
|
|
||||||
|
class WEICreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
|
||||||
|
"""
|
||||||
|
Create WEI
|
||||||
|
"""
|
||||||
|
model = WEIClub
|
||||||
|
form_class = WEIForm
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.instance.requires_membership = True
|
||||||
|
form.instance.parent_club = Club.objects.get(name="Kfet")
|
||||||
|
ret = super().form_valid(form)
|
||||||
|
NoteClub.objects.create(club=form.instance)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
self.object.refresh_from_db()
|
||||||
|
return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
View WEI information
|
View WEI information
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h4>
|
</h4>
|
||||||
<input class="form-control mx-auto w-25" type="text" onkeyup="search_field_moved()" id="search_field"/>
|
<input class="form-control mx-auto w-25" type="text" onkeyup="search_field_moved()" id="search_field"/>
|
||||||
<hr>
|
<hr>
|
||||||
<a class="btn btn-primary text-center my-4" href="{% url 'member:club_create' %}">{% trans "Create WEI" %}</a>
|
<a class="btn btn-primary text-center my-4" href="{% url 'wei:wei_create' %}">{% trans "Create WEI" %}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
|
|
Loading…
Reference in New Issue