Rename TemplateTransaction into RecurrentTransaction

This commit is contained in:
Yohann D'ANELLO 2020-03-19 20:37:48 +01:00
parent 74c0fcca83
commit 801f948a7d
7 changed files with 17 additions and 17 deletions

View File

@ -8,7 +8,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin, \
from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \ from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \
TemplateTransaction, MembershipTransaction RecurrentTransaction, MembershipTransaction
class AliasInlines(admin.TabularInline): class AliasInlines(admin.TabularInline):
@ -102,7 +102,7 @@ class TransactionAdmin(PolymorphicParentModelAdmin):
""" """
Admin customisation for Transaction Admin customisation for Transaction
""" """
child_models = (TemplateTransaction, MembershipTransaction) child_models = (RecurrentTransaction, MembershipTransaction)
list_display = ('created_at', 'poly_source', 'poly_destination', list_display = ('created_at', 'poly_source', 'poly_destination',
'quantity', 'amount', 'valid') 'quantity', 'amount', 'valid')
list_filter = ('valid',) list_filter = ('valid',)

View File

@ -8,7 +8,7 @@ from member.backends import PermissionBackend
from note_kfet.middlewares import get_current_authenticated_user from note_kfet.middlewares import get_current_authenticated_user
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory, \ from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory, \
TemplateTransaction, SpecialTransaction RecurrentTransaction, SpecialTransaction
class NoteSerializer(serializers.ModelSerializer): class NoteSerializer(serializers.ModelSerializer):
@ -135,14 +135,14 @@ class TransactionSerializer(serializers.ModelSerializer):
fields = '__all__' fields = '__all__'
class TemplateTransactionSerializer(serializers.ModelSerializer): class RecurrentTransactionSerializer(serializers.ModelSerializer):
""" """
REST API Serializer for Transactions. REST API Serializer for Transactions.
The djangorestframework plugin will analyse the model `TemplateTransaction` and parse all fields in the API. The djangorestframework plugin will analyse the model `RecurrentTransaction` and parse all fields in the API.
""" """
class Meta: class Meta:
model = TemplateTransaction model = RecurrentTransaction
fields = '__all__' fields = '__all__'
@ -171,7 +171,7 @@ class SpecialTransactionSerializer(serializers.ModelSerializer):
class TransactionPolymorphicSerializer(PolymorphicSerializer): class TransactionPolymorphicSerializer(PolymorphicSerializer):
model_serializer_mapping = { model_serializer_mapping = {
Transaction: TransactionSerializer, Transaction: TransactionSerializer,
TemplateTransaction: TemplateTransactionSerializer, RecurrentTransaction: RecurrentTransactionSerializer,
MembershipTransaction: MembershipTransactionSerializer, MembershipTransaction: MembershipTransactionSerializer,
SpecialTransaction: SpecialTransactionSerializer, SpecialTransaction: SpecialTransactionSerializer,
} }

View File

@ -3,12 +3,12 @@
from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
from .transactions import MembershipTransaction, Transaction, \ from .transactions import MembershipTransaction, Transaction, \
TemplateCategory, TransactionTemplate, TemplateTransaction TemplateCategory, TransactionTemplate, RecurrentTransaction
__all__ = [ __all__ = [
# Notes # Notes
'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser', 'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser',
# Transactions # Transactions
'MembershipTransaction', 'Transaction', 'TemplateCategory', 'TransactionTemplate', 'MembershipTransaction', 'Transaction', 'TemplateCategory', 'TransactionTemplate',
'TemplateTransaction', 'RecurrentTransaction',
] ]

View File

@ -168,7 +168,7 @@ class Transaction(PolymorphicModel):
return _('Transfer') return _('Transfer')
class TemplateTransaction(Transaction): class RecurrentTransaction(Transaction):
""" """
Special type of :model:`note.Transaction` associated to a :model:`note.TransactionTemplate`. Special type of :model:`note.Transaction` associated to a :model:`note.TransactionTemplate`.
""" """

View File

@ -11,7 +11,7 @@ from django_tables2 import SingleTableView
from member.backends import PermissionBackend from member.backends import PermissionBackend
from .forms import TransactionTemplateForm from .forms import TransactionTemplateForm
from .models import Transaction, TransactionTemplate, Alias, TemplateTransaction, NoteSpecial from .models import Transaction, TransactionTemplate, Alias, RecurrentTransaction, NoteSpecial
from .models.transactions import SpecialTransaction from .models.transactions import SpecialTransaction
from .tables import HistoryTable from .tables import HistoryTable
@ -139,11 +139,11 @@ class ConsoView(LoginRequiredMixin, SingleTableView):
from django.db.models import Count from django.db.models import Count
buttons = TransactionTemplate.objects.filter(PermissionBackend() buttons = TransactionTemplate.objects.filter(PermissionBackend()
.filter_queryset(self.request.user, TransactionTemplate, "view")) \ .filter_queryset(self.request.user, TransactionTemplate, "view")) \
.filter(display=True).annotate(clicks=Count('templatetransaction')).order_by('category__name', 'name') .filter(display=True).annotate(clicks=Count('recurrenttransaction')).order_by('category__name', 'name')
context['transaction_templates'] = buttons context['transaction_templates'] = buttons
context['most_used'] = buttons.order_by('-clicks', 'name')[:10] context['most_used'] = buttons.order_by('-clicks', 'name')[:10]
context['title'] = _("Consumptions") context['title'] = _("Consumptions")
context['polymorphic_ctype'] = ContentType.objects.get_for_model(TemplateTransaction).pk context['polymorphic_ctype'] = ContentType.objects.get_for_model(RecurrentTransaction).pk
# select2 compatibility # select2 compatibility
context['no_cache'] = True context['no_cache'] = True

View File

@ -265,7 +265,7 @@ function de_validate(id, validated) {
"X-CSRFTOKEN": CSRF_TOKEN "X-CSRFTOKEN": CSRF_TOKEN
}, },
data: { data: {
"resourcetype": "TemplateTransaction", "resourcetype": "RecurrentTransaction",
valid: !validated valid: !validated
}, },
success: function () { success: function () {

View File

@ -97,7 +97,7 @@ autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display,
* Add a transaction from a button. * Add a transaction from a button.
* @param dest Where the money goes * @param dest Where the money goes
* @param amount The price of the item * @param amount The price of the item
* @param type The type of the transaction (content type id for TemplateTransaction) * @param type The type of the transaction (content type id for RecurrentTransaction)
* @param category_id The category identifier * @param category_id The category identifier
* @param category_name The category name * @param category_name The category name
* @param template_id The identifier of the button * @param template_id The identifier of the button
@ -180,7 +180,7 @@ function consumeAll() {
* @param quantity The quantity sold (type: int) * @param quantity The quantity sold (type: int)
* @param amount The price of one item, in cents (type: int) * @param amount The price of one item, in cents (type: int)
* @param reason The transaction details (type: str) * @param reason The transaction details (type: str)
* @param type The type of the transaction (content type id for TemplateTransaction) * @param type The type of the transaction (content type id for RecurrentTransaction)
* @param category The category id of the button (type: int) * @param category The category id of the button (type: int)
* @param template The button id (type: int) * @param template The button id (type: int)
*/ */
@ -193,7 +193,7 @@ function consume(source, dest, quantity, amount, reason, type, category, templat
"reason": reason, "reason": reason,
"valid": true, "valid": true,
"polymorphic_ctype": type, "polymorphic_ctype": type,
"resourcetype": "TemplateTransaction", "resourcetype": "RecurrentTransaction",
"source": source, "source": source,
"destination": dest, "destination": dest,
"category": category, "category": category,