add basic transactiontemplate handling

This commit is contained in:
Pierre-antoine Comby 2019-08-11 19:54:18 +02:00
parent f6464c2a14
commit edbcf9629c
5 changed files with 30 additions and 9 deletions

View File

@ -48,7 +48,7 @@ class NoteClubAdmin(PolymorphicChildModelAdmin):
# We can't change club after creation or the balance # We can't change club after creation or the balance
readonly_fields = ('club', 'balance') readonly_fields = ('club', 'balance')
search_fields = ('club',)
def has_add_permission(self, request): def has_add_permission(self, request):
""" """
A club note should not be manually added A club note should not be manually added

View File

@ -6,7 +6,7 @@ from django.db import models
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from .notes import Note from .notes import Note,NoteClub
""" """
Defines transactions Defines transactions
@ -19,7 +19,7 @@ class TransactionTemplate(models.Model):
max_length=255, max_length=255,
) )
destination = models.ForeignKey( destination = models.ForeignKey(
Note, NoteClub,
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name='+', # no reverse related_name='+', # no reverse
verbose_name=_('destination'), verbose_name=_('destination'),

View File

@ -9,4 +9,7 @@ from . import views
app_name = 'note' app_name = 'note'
urlpatterns = [ urlpatterns = [
path('transfer/', views.TransactionCreate.as_view(), name='transfer'), path('transfer/', views.TransactionCreate.as_view(), name='transfer'),
path('buttons/create/',views.TransactionTemplateCreateView.as_view(),name='template_create'),
path('buttons/detail/<int:pk>/',views.TransactionTemplateDetailView.as_view(),name='template_detail'),
path('buttons/',views.TransactionTemplateListView.as_view(),name='template_list')
] ]

View File

@ -4,10 +4,10 @@
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.generic.edit import CreateView from django.views.generic import CreateView, ListView, DetailView
from .models import Transaction
from .models import Transaction,TransactionTemplate
from .forms import TransactionTemplateForm
class TransactionCreate(LoginRequiredMixin, CreateView): class TransactionCreate(LoginRequiredMixin, CreateView):
""" """
@ -26,3 +26,20 @@ class TransactionCreate(LoginRequiredMixin, CreateView):
context['title'] = _('Transfer money from your account ' context['title'] = _('Transfer money from your account '
'to one or others') 'to one or others')
return context return context
class TransactionTemplateCreateView(LoginRequiredMixin,CreateView):
"""
Create TransactionTemplate
"""
model = TransactionTemplate
form_class = TransactionTemplateForm
class TransactionTemplateListView(LoginRequiredMixin,ListView):
"""
List TransactionsTemplates
"""
model = TransactionTemplate
form_class = TransactionTemplateForm
class TransactionTemplateDetailView(LoginRequiredMixin,DetailView):
"""
"""
model = TransactionTemplate

View File

@ -28,9 +28,7 @@
<div class="collapse navbar-collapse" id="navbarNavDropdown"> <div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#"> <a class="nav-link" href="#"><i class="fa fa-coffee"></i>Consos</a>
<i class="fa fa-coffee"></i>
Consos </a>
</li> </li>
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-users"></i> Membres</a> <a class="nav-link" href="#"><i class="fa fa-users"></i> Membres</a>
@ -38,6 +36,9 @@
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a> <a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
</li> </li>
<li class="nav-item active">
<a class="nav-link" href="{% url 'note:template_list' %}"><i class="fa fa-coffee"></i> Bouton</a>
</li>
</ul> </ul>
<ul class="navbar-nav ml-auto"> <ul class="navbar-nav ml-auto">