Improve file moderation

This commit is contained in:
Skia 2016-10-26 19:21:19 +02:00
parent 9e32840549
commit 0b068d3e92
4 changed files with 32 additions and 14 deletions

View File

@ -45,6 +45,7 @@ class Command(BaseCommand):
home_root.save() home_root.save()
club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root) club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root)
club_root.save() club_root.save()
SithFile(parent=None, name="SAS", is_folder=True, owner=root).save()
main_club = Club(id=1, name=settings.SITH_MAIN_CLUB['name'], unix_name=settings.SITH_MAIN_CLUB['unix_name'], main_club = Club(id=1, name=settings.SITH_MAIN_CLUB['name'], unix_name=settings.SITH_MAIN_CLUB['unix_name'],
address=settings.SITH_MAIN_CLUB['address']) address=settings.SITH_MAIN_CLUB['address'])
main_club.save() main_club.save()
@ -191,6 +192,14 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
PageRev(page=p, title="README", author=skia, content=rm.read()).save() PageRev(page=p, title="README", author=skia, content=rm.read()).save()
# Subscription # Subscription
## Root
s = Subscription(member=Subscriber.objects.filter(pk=root.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0],
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
s.subscription_start = s.compute_start()
s.subscription_end = s.compute_end(
duration=settings.SITH_SUBSCRIPTIONS[s.subscription_type]['duration'],
start=s.subscription_start)
s.save()
## Skia ## Skia
s = Subscription(member=Subscriber.objects.filter(pk=skia.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0], s = Subscription(member=Subscriber.objects.filter(pk=skia.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0],
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0]) payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])

View File

@ -195,7 +195,13 @@ class User(AbstractBaseUser):
return self.__dict__ return self.__dict__
def is_in_group(self, group_name): def is_in_group(self, group_name):
"""If the user is in the group passed in argument (as string)""" """If the user is in the group passed in argument (as string or by id)"""
if isinstance(group_name, int): # Handle the case where group_name is an ID
g = Group.objects.filter(id=group_name).first()
if g:
group_name = g.name
else:
return False
if group_name == settings.SITH_GROUPS['public']['name']: if group_name == settings.SITH_GROUPS['public']['name']:
return True return True
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked

View File

@ -19,13 +19,13 @@ import os
from core.models import SithFile from core.models import SithFile
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, can_view, not_found from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, can_view, not_found
def send_file(request, file_id): def send_file(request, file_id, file_class=SithFile):
""" """
Send a file through Django without loading the whole file into Send a file through Django without loading the whole file into
memory at once. The FileWrapper will turn the file object into an memory at once. The FileWrapper will turn the file object into an
iterator for chunks of 8KB. iterator for chunks of 8KB.
""" """
f = SithFile.objects.filter(id=file_id).first() f = file_class.objects.filter(id=file_id).first()
if f is None or f.is_folder: if f is None or f.is_folder:
return not_found(request) return not_found(request)
from counter.models import Counter from counter.models import Counter

View File

@ -203,6 +203,19 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST="localhost" EMAIL_HOST="localhost"
EMAIL_PORT=25 EMAIL_PORT=25
# Below this line, only Sith-specific variables are defined
IS_OLD_MYSQL_PRESENT = False
OLD_MYSQL_INFOS = {
'host': 'ae-db',
'user': "my_user",
'passwd': "password",
'db': "ae2-db",
'charset': 'utf8',
'use_unicode': True,
}
SITH_URL = "my.url.git.an" SITH_URL = "my.url.git.an"
SITH_NAME = "Sith website" SITH_NAME = "Sith website"
@ -413,7 +426,7 @@ SITH_BARMAN_TIMEOUT=20
SITH_LAST_OPERATIONS_LIMIT=5 SITH_LAST_OPERATIONS_LIMIT=5
# Minutes for a counter to be inactive # Minutes for a counter to be inactive
SITH_COUNTER_MINUTE_INACTIVE=10 SITH_COUNTER_MINUTE_INACTIVE=10
# ET variables # ET variables
SITH_EBOUTIC_ET_URL = "https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi" SITH_EBOUTIC_ET_URL = "https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi"
@ -432,16 +445,6 @@ SITH_LAUNDERETTE_PRICES = {
'DRYING': 0.75, 'DRYING': 0.75,
} }
IS_OLD_MYSQL_PRESENT = False
OLD_MYSQL_INFOS = {
'host': 'ae-db',
'user': "my_user",
'passwd': "password",
'db': "ae2-db",
'charset': 'utf8',
'use_unicode': True,
}
try: try:
from .settings_custom import * from .settings_custom import *
print("Custom settings imported") print("Custom settings imported")