mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 09:03:06 +00:00 
			
		
		
		
	Improve file moderation
This commit is contained in:
		| @@ -45,6 +45,7 @@ class Command(BaseCommand): | ||||
|         home_root.save() | ||||
|         club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root) | ||||
|         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'], | ||||
|                 address=settings.SITH_MAIN_CLUB['address']) | ||||
|         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() | ||||
|  | ||||
|             # 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 | ||||
|             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]) | ||||
|   | ||||
| @@ -195,7 +195,13 @@ class User(AbstractBaseUser): | ||||
|         return self.__dict__ | ||||
|  | ||||
|     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']: | ||||
|             return True | ||||
|         if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked | ||||
|   | ||||
| @@ -19,13 +19,13 @@ import os | ||||
| from core.models import SithFile | ||||
| 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 | ||||
|     memory at once. The FileWrapper will turn the file object into an | ||||
|     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: | ||||
|         return not_found(request) | ||||
|     from counter.models import Counter | ||||
|   | ||||
| @@ -203,6 +203,19 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||||
| EMAIL_HOST="localhost" | ||||
| 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_NAME = "Sith website" | ||||
|  | ||||
| @@ -432,16 +445,6 @@ SITH_LAUNDERETTE_PRICES = { | ||||
|         '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: | ||||
|     from .settings_custom import * | ||||
|     print("Custom settings imported") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user