mirror of https://gitlab.crans.org/bde/nk20
Fix formatting issues
This commit is contained in:
parent
cd98f96cd0
commit
e679a4b629
|
@ -2,9 +2,10 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from ..models import ActivityType, Activity, Guest
|
||||
from rest_framework import serializers
|
||||
|
||||
from ..models import ActivityType, Activity, Guest
|
||||
|
||||
|
||||
class ActivityTypeSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
from django.conf.urls import url, include
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework import routers, serializers, viewsets
|
||||
from rest_framework.authtoken import views as token_views
|
||||
|
||||
from activity.api.urls import register_activity_urls
|
||||
from member.api.urls import register_members_urls
|
||||
from note.api.urls import register_note_urls
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from ..models import Profile, Club, Role, Membership
|
||||
from rest_framework import serializers
|
||||
|
||||
from ..models import Profile, Club, Role, Membership
|
||||
|
||||
|
||||
class ProfileSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django_filters import FilterSet, CharFilter, NumberFilter
|
||||
from django_filters import FilterSet, CharFilter
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import CharField
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Layout, Submit
|
||||
|
||||
from .models import Club
|
||||
|
||||
|
||||
class UserFilter(FilterSet):
|
||||
class Meta:
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from dal import autocomplete
|
||||
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from django import forms
|
||||
|
||||
from .models import Profile, Club, Membership
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms import layout, bootstrap
|
||||
from crispy_forms.bootstrap import InlineField, FormActions, StrictButton, Div, Field
|
||||
from crispy_forms.bootstrap import Div
|
||||
from crispy_forms.layout import Layout
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse, reverse_lazy
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import django_tables2 as tables
|
||||
from .models import Club
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .models import Club
|
||||
|
||||
|
||||
class ClubTable(tables.Table):
|
||||
class Meta:
|
||||
|
|
|
@ -10,16 +10,16 @@ from . import views
|
|||
|
||||
app_name = 'member'
|
||||
urlpatterns = [
|
||||
path('signup/',views.UserCreateView.as_view(),name="signup"),
|
||||
path('club/',views.ClubListView.as_view(),name="club_list"),
|
||||
path('club/<int:pk>/',views.ClubDetailView.as_view(),name="club_detail"),
|
||||
path('club/<int:pk>/add_member/',views.ClubAddMemberView.as_view(),name="club_add_member"),
|
||||
path('club/create/',views.ClubCreateView.as_view(),name="club_create"),
|
||||
path('user/',views.UserListView.as_view(),name="user_list"),
|
||||
path('user/<int:pk>',views.UserDetailView.as_view(),name="user_detail"),
|
||||
path('user/<int:pk>/update',views.UserUpdateView.as_view(),name="user_update_profile"),
|
||||
path('signup/', views.UserCreateView.as_view(), name="signup"),
|
||||
path('club/', views.ClubListView.as_view(), name="club_list"),
|
||||
path('club/<int:pk>/', views.ClubDetailView.as_view(), name="club_detail"),
|
||||
path('club/<int:pk>/add_member/', views.ClubAddMemberView.as_view(), name="club_add_member"),
|
||||
path('club/create/', views.ClubCreateView.as_view(), name="club_create"),
|
||||
path('user/', views.UserListView.as_view(), name="user_list"),
|
||||
path('user/<int:pk>', views.UserDetailView.as_view(), name="user_detail"),
|
||||
path('user/<int:pk>/update', views.UserUpdateView.as_view(), name="user_update_profile"),
|
||||
path('manage-auth-token/', views.ManageAuthTokens.as_view(), name='auth_token'),
|
||||
|
||||
# API for the user autocompleter
|
||||
path('user/user-autocomplete',views.UserAutocomplete.as_view(),name="user_autocomplete"),
|
||||
path('user/user-autocomplete', views.UserAutocomplete.as_view(), name="user_autocomplete"),
|
||||
]
|
||||
|
|
|
@ -6,23 +6,21 @@ from dal import autocomplete
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, ListView, DetailView, UpdateView, RedirectView, TemplateView
|
||||
from django.views.generic import CreateView, DetailView, UpdateView, TemplateView
|
||||
from django.contrib.auth.models import User
|
||||
from django.urls import reverse_lazy
|
||||
from django.db.models import Q
|
||||
|
||||
from django_tables2.views import SingleTableView
|
||||
from rest_framework.authtoken.models import Token
|
||||
from note.models import Alias, NoteUser
|
||||
from note.models.transactions import Transaction
|
||||
from note.tables import HistoryTable
|
||||
|
||||
from note.models import Alias, Note, NoteUser
|
||||
from .models import Profile, Club, Membership
|
||||
from .forms import SignUpForm, ProfileForm, ClubForm, MembershipForm, MemberFormSet, FormSetHelper
|
||||
from .tables import ClubTable, UserTable
|
||||
from .filters import UserFilter, UserFilterFormHelper
|
||||
|
||||
from note.models.transactions import Transaction
|
||||
from note.tables import HistoryTable
|
||||
|
||||
|
||||
class UserCreateView(CreateView):
|
||||
"""
|
||||
|
@ -197,9 +195,9 @@ class UserAutocomplete(autocomplete.Select2QuerySetView):
|
|||
return qs
|
||||
|
||||
|
||||
###################################
|
||||
############## CLUB ###############
|
||||
###################################
|
||||
# ******************************* #
|
||||
# CLUB #
|
||||
# ******************************* #
|
||||
|
||||
|
||||
class ClubCreateView(LoginRequiredMixin, CreateView):
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||
from rest_framework import serializers
|
||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||
|
||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||
|
||||
|
||||
class NoteSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
|
|
@ -75,12 +75,12 @@ class NotePolymorphicViewSet(viewsets.ModelViewSet):
|
|||
|
||||
note_type = self.request.query_params.get("type", None)
|
||||
if note_type:
|
||||
l = str(note_type).lower()
|
||||
if "user" in l:
|
||||
types = str(note_type).lower()
|
||||
if "user" in types:
|
||||
queryset = queryset.filter(polymorphic_ctype__model="noteuser")
|
||||
elif "club" in l:
|
||||
elif "club" in types:
|
||||
queryset = queryset.filter(polymorphic_ctype__model="noteclub")
|
||||
elif "special" in l:
|
||||
elif "special" in types:
|
||||
queryset = queryset.filter(
|
||||
polymorphic_ctype__model="notespecial")
|
||||
else:
|
||||
|
@ -116,14 +116,14 @@ class AliasViewSet(viewsets.ModelViewSet):
|
|||
|
||||
note_type = self.request.query_params.get("type", None)
|
||||
if note_type:
|
||||
l = str(note_type).lower()
|
||||
if "user" in l:
|
||||
types = str(note_type).lower()
|
||||
if "user" in types:
|
||||
queryset = queryset.filter(
|
||||
note__polymorphic_ctype__model="noteuser")
|
||||
elif "club" in l:
|
||||
elif "club" in types:
|
||||
queryset = queryset.filter(
|
||||
note__polymorphic_ctype__model="noteclub")
|
||||
elif "special" in l:
|
||||
elif "special" in types:
|
||||
queryset = queryset.filter(
|
||||
note__polymorphic_ctype__model="notespecial")
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from dal import autocomplete, forward
|
||||
from dal import autocomplete
|
||||
from django import forms
|
||||
|
||||
from .models import Transaction, TransactionTemplate
|
||||
|
||||
|
||||
|
|
|
@ -7,12 +7,13 @@ from django.utils import timezone
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse
|
||||
|
||||
from .notes import Note,NoteClub
|
||||
from .notes import Note, NoteClub
|
||||
|
||||
"""
|
||||
Defines transactions
|
||||
"""
|
||||
|
||||
|
||||
class TransactionCategory(models.Model):
|
||||
"""
|
||||
Defined a recurrent transaction category
|
||||
|
@ -32,6 +33,7 @@ class TransactionCategory(models.Model):
|
|||
def __str__(self):
|
||||
return str(self.name)
|
||||
|
||||
|
||||
class TransactionTemplate(models.Model):
|
||||
"""
|
||||
Defined a recurrent transaction
|
||||
|
@ -57,7 +59,7 @@ class TransactionTemplate(models.Model):
|
|||
TransactionCategory,
|
||||
on_delete=models.PROTECT,
|
||||
verbose_name=_('type'),
|
||||
max_length=31
|
||||
max_length=31,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -65,7 +67,7 @@ class TransactionTemplate(models.Model):
|
|||
verbose_name_plural = _("transaction templates")
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('note:template_update',args=(self.pk,))
|
||||
return reverse('note:template_update', args=(self.pk, ))
|
||||
|
||||
|
||||
class Transaction(models.Model):
|
||||
|
@ -98,9 +100,7 @@ class Transaction(models.Model):
|
|||
verbose_name=_('quantity'),
|
||||
default=1,
|
||||
)
|
||||
amount = models.PositiveIntegerField(
|
||||
verbose_name=_('amount'),
|
||||
)
|
||||
amount = models.PositiveIntegerField(verbose_name=_('amount'), )
|
||||
transaction_type = models.CharField(
|
||||
verbose_name=_('type'),
|
||||
max_length=31,
|
||||
|
@ -142,7 +142,7 @@ class Transaction(models.Model):
|
|||
|
||||
@property
|
||||
def total(self):
|
||||
return self.amount*self.quantity
|
||||
return self.amount * self.quantity
|
||||
|
||||
|
||||
class MembershipTransaction(Transaction):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
import django_tables2 as tables
|
||||
from django.db.models import F
|
||||
|
||||
|
@ -15,11 +14,10 @@ class HistoryTable(tables.Table):
|
|||
template_name = 'django_tables2/bootstrap.html'
|
||||
sequence = ('...', 'total', 'valid')
|
||||
|
||||
total = tables.Column() #will use Transaction.total() !!
|
||||
total = tables.Column() # will use Transaction.total() !!
|
||||
|
||||
def order_total(self, QuerySet, is_descending):
|
||||
def order_total(self, queryset, is_descending):
|
||||
# needed for rendering
|
||||
QuerySet = QuerySet.annotate(
|
||||
total=F('amount') *
|
||||
F('quantity')).order_by(('-' if is_descending else '') + 'total')
|
||||
return (QuerySet, True)
|
||||
queryset = queryset.annotate(total=F('amount') * F('quantity')) \
|
||||
.order_by(('-' if is_descending else '') + 'total')
|
||||
return (queryset, True)
|
||||
|
|
|
@ -10,12 +10,12 @@ from .models import Note
|
|||
app_name = 'note'
|
||||
urlpatterns = [
|
||||
path('transfer/', views.TransactionCreate.as_view(), name='transfer'),
|
||||
path('buttons/create/',views.TransactionTemplateCreateView.as_view(),name='template_create'),
|
||||
path('buttons/update/<int:pk>/',views.TransactionTemplateUpdateView.as_view(),name='template_update'),
|
||||
path('buttons/',views.TransactionTemplateListView.as_view(),name='template_list'),
|
||||
path('consos/<str:template_type>/',views.ConsoView.as_view(),name='consos'),
|
||||
path('consos/',views.ConsoView.as_view(),name='consos'),
|
||||
path('buttons/create/', views.TransactionTemplateCreateView.as_view(), name='template_create'),
|
||||
path('buttons/update/<int:pk>/', views.TransactionTemplateUpdateView.as_view(), name='template_update'),
|
||||
path('buttons/', views.TransactionTemplateListView.as_view(), name='template_list'),
|
||||
path('consos/<str:template_type>/', views.ConsoView.as_view(), name='consos'),
|
||||
path('consos/', views.ConsoView.as_view(), name='consos'),
|
||||
|
||||
# API for the note autocompleter
|
||||
path('note-autocomplete/', views.NoteAutocomplete.as_view(model=Note),name='note_autocomplete'),
|
||||
path('note-autocomplete/', views.NoteAutocomplete.as_view(model=Note), name='note_autocomplete'),
|
||||
]
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
from dal import autocomplete
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.db.models import Q
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, ListView, DetailView, UpdateView
|
||||
from django.views.generic import CreateView, ListView, UpdateView
|
||||
|
||||
from .models import Note, Transaction, TransactionCategory, TransactionTemplate, Alias
|
||||
from .models import Transaction, TransactionCategory, TransactionTemplate, Alias
|
||||
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
|
||||
|
||||
|
||||
|
@ -75,12 +75,12 @@ class NoteAutocomplete(autocomplete.Select2QuerySetView):
|
|||
# Filtrage par type de note (user, club, special)
|
||||
note_type = self.forwarded.get("note_type", None)
|
||||
if note_type:
|
||||
l = str(note_type).lower()
|
||||
if "user" in l:
|
||||
types = str(note_type).lower()
|
||||
if "user" in types:
|
||||
qs = qs.filter(note__polymorphic_ctype__model="noteuser")
|
||||
elif "club" in l:
|
||||
elif "club" in types:
|
||||
qs = qs.filter(note__polymorphic_ctype__model="noteclub")
|
||||
elif "special" in l:
|
||||
elif "special" in types:
|
||||
qs = qs.filter(note__polymorphic_ctype__model="notespecial")
|
||||
else:
|
||||
qs = qs.none()
|
||||
|
|
Loading…
Reference in New Issue