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