mirror of https://gitlab.crans.org/bde/nk20
Compare commits
15 Commits
93f7e1d45b
...
434a393f3b
Author | SHA1 | Date |
---|---|---|
Yohann D'ANELLO | 434a393f3b | |
Yohann D'ANELLO | cba6a35b6c | |
Yohann D'ANELLO | 0de69cbfaf | |
Yohann D'ANELLO | d9cf812074 | |
Yohann D'ANELLO | 252ddb832d | |
Yohann D'ANELLO | 6dcb82855d | |
Yohann D'ANELLO | 1247818033 | |
Yohann D'ANELLO | 9439b3cb2d | |
Yohann D'ANELLO | a07b942738 | |
Yohann D'ANELLO | b7ae411f96 | |
Yohann D'ANELLO | 315af75c45 | |
Yohann D'ANELLO | fd7e314ca3 | |
Yohann D'ANELLO | 0b46140771 | |
Yohann D'ANELLO | 547fbf564b | |
Yohann D'ANELLO | 2aebeb8927 |
|
@ -16,3 +16,5 @@ EMAIL_HOST=smtp.localhost
|
|||
EMAIL_PORT=465
|
||||
EMAIL_USER=notekfet@localhost
|
||||
EMAIL_PASSWORD=CHANGE_ME
|
||||
WIKI_USER=NoteKfet2020
|
||||
WIKI_PASSWORD=
|
|
@ -39,6 +39,7 @@ secrets.py
|
|||
.env
|
||||
map.json
|
||||
*.log
|
||||
backups/
|
||||
media/
|
||||
|
||||
# Virtualenv
|
||||
|
|
|
@ -124,6 +124,8 @@ On supposera pour la suite que vous utilisez Debian/Ubuntu sur un serveur tout n
|
|||
EMAIL_PORT=465
|
||||
EMAIL_USER=notekfet@localhost
|
||||
EMAIL_PASSWORD=CHANGE_ME
|
||||
WIKI_USER=NoteKfet2020
|
||||
WIKI_PASSWORD=CHANGE_ME
|
||||
|
||||
|
||||
Ensuite on (re)bascule dans l'environement virtuel et on lance les migrations
|
||||
|
|
|
@ -41,3 +41,9 @@
|
|||
systemd:
|
||||
name: cron
|
||||
state: restarted
|
||||
|
||||
- name: Update permissions for the cron file
|
||||
file:
|
||||
path: /var/www/note_kfet/note.cron
|
||||
owner: root
|
||||
group: www-data
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from note_kfet.admin import admin_site
|
||||
|
||||
from .models import Activity, ActivityType, Guest, Entry
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
from threading import Thread
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
@ -54,6 +57,13 @@ class Activity(models.Model):
|
|||
verbose_name=_('description'),
|
||||
)
|
||||
|
||||
location = models.CharField(
|
||||
verbose_name=_('location'),
|
||||
max_length=255,
|
||||
blank=True,
|
||||
default="",
|
||||
)
|
||||
|
||||
activity_type = models.ForeignKey(
|
||||
ActivityType,
|
||||
on_delete=models.PROTECT,
|
||||
|
@ -99,6 +109,19 @@ class Activity(models.Model):
|
|||
verbose_name=_('open'),
|
||||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""
|
||||
Update the activity wiki page each time the activity is updated (validation, change description, ...)
|
||||
"""
|
||||
ret = super().save(*args, **kwargs)
|
||||
if self.pk and "scripts" in settings.INSTALLED_APPS:
|
||||
def refresh_activities():
|
||||
from scripts.management.commands.refresh_activities import Command as RefreshActivitiesCommand
|
||||
RefreshActivitiesCommand.refresh_human_readable_wiki_page("Modification de l'activité " + self.name)
|
||||
RefreshActivitiesCommand.refresh_raw_wiki_page("Modification de l'activité " + self.name)
|
||||
Thread(daemon=True, target=refresh_activities).start()
|
||||
return ret
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ EXCLUDED = [
|
|||
'cas_server.userattributes',
|
||||
'contenttypes.contenttype',
|
||||
'logs.changelog', # Never remove this line
|
||||
'mailer.dontsendentry',
|
||||
'mailer.message',
|
||||
'mailer.messagelog',
|
||||
'migrations.migration',
|
||||
'note.note' # We only store the subclasses
|
||||
'note.transaction',
|
||||
|
|
|
@ -16,7 +16,6 @@ from django.utils.encoding import force_bytes
|
|||
from django.utils.http import urlsafe_base64_encode
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
||||
from permission.models import Role
|
||||
from registration.tokens import email_validation_token
|
||||
from note.models import MembershipTransaction
|
||||
|
@ -155,12 +154,12 @@ class Profile(models.Model):
|
|||
'uid': urlsafe_base64_encode(force_bytes(self.user.pk)),
|
||||
})
|
||||
html = loader.render_to_string('registration/mails/email_validation_email.html',
|
||||
{
|
||||
'user': self.user,
|
||||
'domain': os.getenv("NOTE_URL", "note.example.com"),
|
||||
'token': email_validation_token.make_token(self.user),
|
||||
'uid': urlsafe_base64_encode(force_bytes(self.user.pk)),
|
||||
})
|
||||
{
|
||||
'user': self.user,
|
||||
'domain': os.getenv("NOTE_URL", "note.example.com"),
|
||||
'token': email_validation_token.make_token(self.user),
|
||||
'uid': urlsafe_base64_encode(force_bytes(self.user.pk)),
|
||||
})
|
||||
self.user.email_user(subject, message, html_message=html)
|
||||
|
||||
|
||||
|
@ -329,7 +328,6 @@ class Membership(models.Model):
|
|||
club=self.club,
|
||||
date_start=max(self.date_end + datetime.timedelta(days=1), self.club.membership_start),
|
||||
)
|
||||
from django.forms import model_to_dict
|
||||
if hasattr(self, '_force_renew_parent') and self._force_renew_parent:
|
||||
new_membership._force_renew_parent = True
|
||||
if hasattr(self, '_soge') and self._soge:
|
||||
|
@ -445,8 +443,8 @@ class Membership(models.Model):
|
|||
)
|
||||
transaction._force_save = True
|
||||
if hasattr(self, '_soge') and "treasury" in settings.INSTALLED_APPS\
|
||||
and (self.club.name == "BDE" or self.club.name == "Kfet" or
|
||||
("wei" in settings.INSTALLED_APPS and hasattr(self.club, "weiclub") and self.club.weiclub)):
|
||||
and (self.club.name == "BDE" or self.club.name == "Kfet"
|
||||
or ("wei" in settings.INSTALLED_APPS and hasattr(self.club, "weiclub") and self.club.weiclub)):
|
||||
# If the soge pays, then the transaction is unvalidated in a first time, then submitted for control
|
||||
# to treasurers.
|
||||
transaction.valid = False
|
||||
|
|
|
@ -38,6 +38,8 @@ class UserTable(tables.Table):
|
|||
"""
|
||||
List all users.
|
||||
"""
|
||||
alias = tables.Column()
|
||||
|
||||
section = tables.Column(accessor='profile.section')
|
||||
|
||||
balance = tables.Column(accessor='note.balance', verbose_name=_("Balance"))
|
||||
|
@ -50,7 +52,7 @@ class UserTable(tables.Table):
|
|||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('last_name', 'first_name', 'username', 'email')
|
||||
fields = ('last_name', 'first_name', 'username', 'alias', 'email')
|
||||
model = User
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.contrib.auth import logout
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.db.models import Q
|
||||
from django.db.models import Q, F
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils import timezone
|
||||
|
@ -172,7 +172,9 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
|||
"""
|
||||
Filter the user list with the given pattern.
|
||||
"""
|
||||
qs = super().get_queryset().distinct().filter(profile__registration_valid=True)
|
||||
qs = super().get_queryset().distinct("pk").annotate(alias=F("note__alias__name"))\
|
||||
.annotate(normalized_alias=F("note__alias__normalized_name"))\
|
||||
.filter(profile__registration_valid=True)
|
||||
if "search" in self.request.GET:
|
||||
pattern = self.request.GET["search"]
|
||||
|
||||
|
@ -184,8 +186,8 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
|||
| Q(last_name__iregex=pattern)
|
||||
| Q(profile__section__iregex=pattern)
|
||||
| Q(username__iregex="^" + pattern)
|
||||
| Q(note__alias__name__iregex="^" + pattern)
|
||||
| Q(note__alias__normalized_name__iregex=Alias.normalize("^" + pattern))
|
||||
| Q(alias__iregex="^" + pattern)
|
||||
| Q(normalized_alias__iregex=Alias.normalize("^" + pattern))
|
||||
)
|
||||
else:
|
||||
qs = qs.none()
|
||||
|
@ -455,7 +457,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
|
|||
while c.parent_club is not None:
|
||||
c = c.parent_club
|
||||
clubs_renewal.append(c)
|
||||
additional_fee_renewal += c.membership_fee_paid if user.profile.paid else c.membership_fee_unpaid
|
||||
additional_fee_renewal += c.membership_fee_paid
|
||||
context["clubs_renewal"] = clubs_renewal
|
||||
context["additional_fee_renewal"] = additional_fee_renewal
|
||||
|
||||
|
@ -496,7 +498,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
|
|||
form.fields['user'].disabled = True
|
||||
form.fields['date_start'].initial = old_membership.date_end + timedelta(days=1)
|
||||
form.fields['credit_amount'].initial = (club.membership_fee_paid if user.profile.paid
|
||||
else club.membership_fee_unpaid) + additional_fee_renewal
|
||||
else club.membership_fee_unpaid) + additional_fee_renewal
|
||||
form.fields['last_name'].initial = user.last_name
|
||||
form.fields['first_name'].initial = user.first_name
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from django.utils import timezone
|
||||
from rest_framework import serializers
|
||||
from rest_framework.serializers import ListSerializer
|
||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||
from member.api.serializers import MembershipSerializer
|
||||
from member.models import Membership
|
||||
from note_kfet.middlewares import get_current_authenticated_user
|
||||
|
|
|
@ -9,7 +9,7 @@ from rest_framework import viewsets
|
|||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from api.viewsets import ReadProtectedModelViewSet, ReadOnlyProtectedModelViewSet
|
||||
from note_kfet.middlewares import get_current_session
|
||||
from note_kfet.middlewares import get_current_session
|
||||
from permission.backends import PermissionBackend
|
||||
|
||||
from .serializers import NotePolymorphicSerializer, AliasSerializer, ConsumerSerializer,\
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.utils import timezone
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
from .notes import Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .notes import Note, NoteClub, NoteSpecial
|
||||
from ..templatetags.pretty_money import pretty_money
|
||||
|
||||
"""
|
||||
|
@ -222,8 +222,7 @@ class Transaction(PolymorphicModel):
|
|||
self.destination_alias = str(self.destination)
|
||||
|
||||
if self.source.pk == self.destination.pk:
|
||||
# When source == destination, no money is transferred
|
||||
super().save(*args, **kwargs)
|
||||
# When source == destination, no money is transferred and no transaction is created
|
||||
return
|
||||
|
||||
self.log("Saving")
|
||||
|
|
|
@ -10,7 +10,6 @@ from django.utils.translation import gettext_lazy as _
|
|||
from django.views.generic import CreateView, UpdateView, DetailView
|
||||
from django_tables2 import SingleTableView
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from activity.models import Entry
|
||||
from note_kfet.inputs import AmountInput
|
||||
from permission.backends import PermissionBackend
|
||||
|
|
|
@ -5,7 +5,6 @@ import functools
|
|||
import json
|
||||
import operator
|
||||
from copy import copy
|
||||
from time import sleep
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import django_tables2 as tables
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.html import format_html
|
||||
|
||||
from member.models import Membership
|
||||
from note_kfet.middlewares import get_current_authenticated_user
|
||||
from permission.backends import PermissionBackend
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 47dc4dd9e6742c3fd0f0d4ea654b1e9a0a39f4f7
|
||||
Subproject commit 3806feb67fcb1fe822cfdedddbbc4ca7eeef3829
|
|
@ -6,7 +6,6 @@ from django.contrib.auth.models import User
|
|||
from django.db.models import Q
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from note.models import NoteSpecial
|
||||
from note_kfet.inputs import AmountInput, DatePickerInput, Autocomplete, ColorWidget
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ from django.contrib.auth.models import User
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
||||
from member.models import Club, Membership
|
||||
from note.models import MembershipTransaction
|
||||
from permission.models import Role
|
||||
|
|
|
@ -7,9 +7,9 @@ from django.utils import timezone
|
|||
from django.utils.html import format_html
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_tables2 import A
|
||||
|
||||
from note_kfet.middlewares import get_current_authenticated_user
|
||||
from permission.backends import PermissionBackend
|
||||
|
||||
from .models import WEIClub, WEIRegistration, Bus, BusTeam, WEIMembership
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ from note.models import Transaction, NoteClub, Alias, SpecialTransaction, NoteSp
|
|||
from note.tables import HistoryTable
|
||||
from note_kfet.settings import BASE_DIR
|
||||
from permission.backends import PermissionBackend
|
||||
from permission.models import Role
|
||||
from permission.views import ProtectQuerysetMixin
|
||||
|
||||
from .forms.registration import WEIChooseBusForm
|
||||
|
|
|
@ -6,14 +6,17 @@
|
|||
* * * * * root cd /var/www/note_kfet && env/bin/python manage.py send_mail >> /var/www/note_kfet/cron_mail.log
|
||||
* * * * * root cd /var/www/note_kfet && env/bin/python manage.py retry_deferred >> /var/www/note_kfet/cron_mail_deferred.log
|
||||
00 0 * * * root cd /var/www/note_kfet && env/bin/python manage.py purge_mail_log 7 >> /var/www/note_kfet/cron_mail_purge.log
|
||||
# Faire une sauvegarde de la base de données
|
||||
00 2 * * * root cd /var/www/note_kfet && apps/scripts/shell/backup_db
|
||||
# Vérifier la cohérence de la base et mailer en cas de problème
|
||||
00 4 * * * root cd /var/www/note_kfet && env/bin/python manage.py check_consistency --sum-all --check-all --mail
|
||||
# TODO
|
||||
# Mettre à jour le wiki (modification sans (dé)validation, activités passées)
|
||||
#30 5 * * * root /home/note/note-kfet-2015-serveur/serveur/Wiki.py --human --raw
|
||||
#30 5 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_activities --raw --comment refresh
|
||||
# Spammer les gens en négatif
|
||||
00 5 * * 2 root cd /var/www/note_kfet && env/bin/python manage.py send_mail_to_negative_balances --spam
|
||||
# Envoyer le rapport mensuel aux trésoriers et respos info
|
||||
00 8 6 * * root cd /var/www/note_kfet && env/bin/python manage.py send_mail_to_negative_balances --report
|
||||
# Envoyer les rapports aux gens
|
||||
55 6 * * * root cd /var/www/note_kfet && env/bin/python manage.py send_reports
|
||||
# Envoyer les rapports aux gens
|
||||
00 9 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_highlighted_buttons
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
beautifulsoup4==4.9.1
|
||||
certifi==2019.6.16
|
||||
chardet==3.0.4
|
||||
defusedxml==0.6.0
|
||||
|
@ -12,6 +13,7 @@ django-polymorphic==2.0.3
|
|||
django-tables2==2.1.0
|
||||
docutils==0.14
|
||||
idna==2.8
|
||||
lxml==4.5.2
|
||||
oauthlib==3.1.0
|
||||
phonenumbers==8.12.7
|
||||
Pillow==7.1.2
|
||||
|
|
|
@ -218,7 +218,7 @@ function consume(source, source_alias, dest, quantity, amount, reason, type, cat
|
|||
addMsg("Attention, La transaction depuis la note " + source_alias + " a été réalisée avec " +
|
||||
"succès, mais la note émettrice " + source_alias + " est en négatif.",
|
||||
"warning", 30000);
|
||||
if (source.note.membership && source.note.membership.date_end > new Date().toISOString())
|
||||
if (source.note.membership && source.note.membership.date_end < new Date().toISOString())
|
||||
addMsg("Attention : la note émettrice " + source.name + " n'est plus adhérente.",
|
||||
"danger", 30000);
|
||||
}
|
||||
|
|
|
@ -246,6 +246,13 @@ $("#btn_transfer").click(function() {
|
|||
// We copy the arrays to ensure that transactions are well-processed even if the form is reset
|
||||
[...sources_notes_display].forEach(function (source) {
|
||||
[...dests_notes_display].forEach(function (dest) {
|
||||
if (source.note.id === dest.note.id) {
|
||||
addMsg("Attention : la transaction de " + pretty_money(amount) + " de la note " + source.name
|
||||
+ " vers la note " + dest.name + " n'a pas été faite car il s'agit de la même note au départ" +
|
||||
" et à l'arrivée.","warning", 10000);
|
||||
return;
|
||||
}
|
||||
|
||||
$.post("/api/note/transaction/transaction/",
|
||||
{
|
||||
"csrfmiddlewaretoken": CSRF_TOKEN,
|
||||
|
@ -260,10 +267,10 @@ $("#btn_transfer").click(function() {
|
|||
"destination": dest.note.id,
|
||||
"destination_alias": dest.name
|
||||
}).done(function () {
|
||||
if (source.note.membership && source.note.membership.date_end > new Date().toISOString())
|
||||
if (source.note.membership && source.note.membership.date_end < new Date().toISOString())
|
||||
addMsg("Attention : la note émettrice " + source.name + " n'est plus adhérente.",
|
||||
"danger", 30000);
|
||||
if (dest.note.membership && dest.note.membership.date_end > new Date().toISOString())
|
||||
if (dest.note.membership && dest.note.membership.date_end < new Date().toISOString())
|
||||
addMsg("Attention : la note destination " + dest.name + " n'est plus adhérente.",
|
||||
"danger", 30000);
|
||||
|
||||
|
@ -373,7 +380,7 @@ $("#btn_transfer").click(function() {
|
|||
"bank": $("#bank").val()
|
||||
}).done(function () {
|
||||
addMsg("Le crédit/retrait a bien été effectué !", "success", 10000);
|
||||
if (user_note.membership && user_note.membership.date_end > new Date().toISOString())
|
||||
if (user_note.membership && user_note.membership.date_end < new Date().toISOString())
|
||||
addMsg("Attention : la note " + alias + " n'est plus adhérente.", "danger", 10000);
|
||||
reset();
|
||||
}).fail(function (err) {
|
||||
|
|
|
@ -22,5 +22,7 @@ socket = /var/www/note_kfet/note_kfet.sock
|
|||
chmod-socket = 664
|
||||
# clear environment on exit
|
||||
vacuum = true
|
||||
#Touch reload
|
||||
touch-reload = /var/www/note_kfet/note_kfet/settings/__init__.py
|
||||
# Touch reload
|
||||
touch-reload = /var/www/note_kfet/note_kfet/settings/__init__.py
|
||||
# Enable threads
|
||||
enable-threads = true
|
Loading…
Reference in New Issue