Commit 041d5304 authored by Florent Chehab's avatar Florent Chehab

File reorganization

parent be54f018
from .myModel import MyModel # noqa: F401
from .myModelSerializer import MyModelSerializer # noqa: F401
from django.db import models
from django.contrib.auth.models import User
from rest_framework import serializers
# from backend.signals import new_revision_saved
# import reversion
from django.utils import timezone
from backend.models.tools import PendingModeration
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
class MyModel(models.Model):
"""
All models in the app deppend of this one.
It contains the required attributes for managing eventual moderation data.
All the logic behind moderation is done in myModelSerializer
"""
moderated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='moderated')
moderated_on = models.DateTimeField(null=True)
updated_on = models.DateTimeField(null=True)
updated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='updated')
class Meta:
abstract = True
# class MyModelVersionned(MyModel):
# class Meta:
# abstract = True
from django.db import models
from django.contrib.auth.models import User
from rest_framework import serializers
# from backend.signals import new_revision_saved
# import reversion
from django.utils import timezone
from backend.models.tools import PendingModeration
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
class MyModel(models.Model):
"""
All models in the app deppend of this one !
"""
moderated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='moderated')
moderated_on = models.DateTimeField(null=True)
updated_on = models.DateTimeField(null=True)
updated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='updated')
class Meta:
abstract = True
# class MyModelVersionned(MyModel):
# class Meta:
# abstract = True
def is_member(group_name, user):
return user.groups.filter(name=group_name).exists()
from .myModel import MyModel
class MyModelSerializer(serializers.ModelSerializer):
......
......@@ -4,5 +4,4 @@ from .scholarship import Scholarship # noqa: F401
from .photo import Photo # noqa: F401
from .driRestrictedModule import DriRestrictedModule, DriRestrictedModuleSerializer # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
from .myModel import MyModel, MyModelSerializer # noqa: F401
# MyModelVersionned, MyModelVersionnedSerializer # noqa: F401
from django.db import models
from backend.models.module import MyModel
from backend.models.moderation import MyModel
from backend.utils.friendly_path import friendly_path
path_and_rename = friendly_path("uploads/universities/logos/", 'name')
......
......@@ -2,7 +2,7 @@ from backend.models.university import University
from rest_framework import viewsets, permissions
from backend.models.university.campus import CampusSerializer
from backend.models.tools import NoDeleteIfNotAdmin
from backend.models.module import MyModelSerializer
from backend.models.moderation import MyModelSerializer
class UniversitySerializer(MyModelSerializer):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment