diff --git a/apps/note/admin.py b/apps/note/admin.py index c6593993..298b91c0 100644 --- a/apps/note/admin.py +++ b/apps/note/admin.py @@ -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 diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 506908bf..c98c33d2 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -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'), diff --git a/apps/note/urls.py b/apps/note/urls.py index aaa6b160..b46e0e85 100644 --- a/apps/note/urls.py +++ b/apps/note/urls.py @@ -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//',views.TransactionTemplateDetailView.as_view(),name='template_detail'), + path('buttons/',views.TransactionTemplateListView.as_view(),name='template_list') ] diff --git a/apps/note/views.py b/apps/note/views.py index e60ec203..59f9f7ec 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -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 diff --git a/templates/base.html b/templates/base.html index 943d443e..49a46dc8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -28,9 +28,7 @@