diff --git a/apps/note/admin.py b/apps/note/admin.py index a0928641..702d3350 100644 --- a/apps/note/admin.py +++ b/apps/note/admin.py @@ -8,7 +8,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin, \ from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \ - TemplateTransaction, MembershipTransaction + RecurrentTransaction, MembershipTransaction class AliasInlines(admin.TabularInline): @@ -102,7 +102,7 @@ class TransactionAdmin(PolymorphicParentModelAdmin): """ Admin customisation for Transaction """ - child_models = (TemplateTransaction, MembershipTransaction) + child_models = (RecurrentTransaction, MembershipTransaction) list_display = ('created_at', 'poly_source', 'poly_destination', 'quantity', 'amount', 'valid') list_filter = ('valid',) diff --git a/apps/note/api/serializers.py b/apps/note/api/serializers.py index 4a62d2f4..c8cf5aa1 100644 --- a/apps/note/api/serializers.py +++ b/apps/note/api/serializers.py @@ -8,7 +8,7 @@ from member.backends import PermissionBackend from note_kfet.middlewares import get_current_authenticated_user from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory, \ - TemplateTransaction, SpecialTransaction + RecurrentTransaction, SpecialTransaction class NoteSerializer(serializers.ModelSerializer): @@ -135,14 +135,14 @@ class TransactionSerializer(serializers.ModelSerializer): fields = '__all__' -class TemplateTransactionSerializer(serializers.ModelSerializer): +class RecurrentTransactionSerializer(serializers.ModelSerializer): """ 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: - model = TemplateTransaction + model = RecurrentTransaction fields = '__all__' @@ -171,7 +171,7 @@ class SpecialTransactionSerializer(serializers.ModelSerializer): class TransactionPolymorphicSerializer(PolymorphicSerializer): model_serializer_mapping = { Transaction: TransactionSerializer, - TemplateTransaction: TemplateTransactionSerializer, + RecurrentTransaction: RecurrentTransactionSerializer, MembershipTransaction: MembershipTransactionSerializer, SpecialTransaction: SpecialTransactionSerializer, } diff --git a/apps/note/models/__init__.py b/apps/note/models/__init__.py index 081b31a7..8f1921f9 100644 --- a/apps/note/models/__init__.py +++ b/apps/note/models/__init__.py @@ -3,12 +3,12 @@ from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser from .transactions import MembershipTransaction, Transaction, \ - TemplateCategory, TransactionTemplate, TemplateTransaction + TemplateCategory, TransactionTemplate, RecurrentTransaction __all__ = [ # Notes 'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser', # Transactions 'MembershipTransaction', 'Transaction', 'TemplateCategory', 'TransactionTemplate', - 'TemplateTransaction', + 'RecurrentTransaction', ] diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index b7c8f092..0e40edf6 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -168,7 +168,7 @@ class Transaction(PolymorphicModel): return _('Transfer') -class TemplateTransaction(Transaction): +class RecurrentTransaction(Transaction): """ Special type of :model:`note.Transaction` associated to a :model:`note.TransactionTemplate`. """ diff --git a/apps/note/views.py b/apps/note/views.py index 6b2cb372..c9905dd2 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -11,7 +11,7 @@ from django_tables2 import SingleTableView from member.backends import PermissionBackend 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 .tables import HistoryTable @@ -139,11 +139,11 @@ class ConsoView(LoginRequiredMixin, SingleTableView): from django.db.models import Count buttons = TransactionTemplate.objects.filter(PermissionBackend() .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['most_used'] = buttons.order_by('-clicks', 'name')[:10] 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 context['no_cache'] = True diff --git a/static/js/base.js b/static/js/base.js index 7a733df3..1cc242e8 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -265,7 +265,7 @@ function de_validate(id, validated) { "X-CSRFTOKEN": CSRF_TOKEN }, data: { - "resourcetype": "TemplateTransaction", + "resourcetype": "RecurrentTransaction", valid: !validated }, success: function () { diff --git a/static/js/consos.js b/static/js/consos.js index 1cf24e07..896f996c 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -97,7 +97,7 @@ autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display, * Add a transaction from a button. * @param dest Where the money goes * @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_name The category name * @param template_id The identifier of the button @@ -180,7 +180,7 @@ function consumeAll() { * @param quantity The quantity sold (type: int) * @param amount The price of one item, in cents (type: int) * @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 template The button id (type: int) */ @@ -193,7 +193,7 @@ function consume(source, dest, quantity, amount, reason, type, category, templat "reason": reason, "valid": true, "polymorphic_ctype": type, - "resourcetype": "TemplateTransaction", + "resourcetype": "RecurrentTransaction", "source": source, "destination": dest, "category": category,