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
readonly_fields = ('club', 'balance')
search_fields = ('club',)
def has_add_permission(self, request):
"""
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.translation import gettext_lazy as _
from .notes import Note
from .notes import Note,NoteClub
"""
Defines transactions
@ -19,7 +19,7 @@ class TransactionTemplate(models.Model):
max_length=255,
)
destination = models.ForeignKey(
Note,
NoteClub,
on_delete=models.PROTECT,
related_name='+', # no reverse
verbose_name=_('destination'),

View File

@ -9,4 +9,7 @@ from . import views
app_name = 'note'
urlpatterns = [
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.utils.translation import gettext_lazy as _
from django.views.generic.edit import CreateView
from .models import Transaction
from django.views.generic import CreateView, ListView, DetailView
from .models import Transaction,TransactionTemplate
from .forms import TransactionTemplateForm
class TransactionCreate(LoginRequiredMixin, CreateView):
"""
@ -26,3 +26,20 @@ class TransactionCreate(LoginRequiredMixin, CreateView):
context['title'] = _('Transfer money from your account '
'to one or others')
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">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">
<i class="fa fa-coffee"></i>
Consos </a>
<a class="nav-link" href="#"><i class="fa fa-coffee"></i>Consos</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-users"></i> Membres</a>
@ -38,6 +36,9 @@
<li class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
</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 class="navbar-nav ml-auto">