Commit b67fda5d authored by Florent Chehab's avatar Florent Chehab

Models reorgranization (again)

parent 9e62f092
Pipeline #27099 passed with stages
in 2 minutes and 46 seconds
from .DictModeViewSet import DictModeViewSet # noqa: F401
from .jSONField import JSONField # noqa: F401
from .mySerializerWithJSON import MySerializerWithJSON # noqa: F401
from .jSONField import JSONField
from backend.fields.jSONField import JSONField
from rest_framework import serializers
field_mapping = serializers.ModelSerializer.serializer_field_mapping
......
from .jSONField import JSONField # noqa: F401
# taken from : https://github.com/devkral/django-simple-jsonfield
# inspired by : https://github.com/devkral/django-simple-jsonfield
# MIT license
from django.core.exceptions import ValidationError
from django.db import models
......
This diff is collapsed.
# Generated by Django 2.0.3 on 2018-09-09 13:47
import backend.models.tools.jSONField
import backend.fields.jSONField
from django.db import migrations, models
......@@ -24,7 +24,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='campustaggeditem',
name='usefull_links',
field=backend.models.tools.jSONField.JSONField(default=list),
field=backend.fields.jSONField.JSONField(default=list),
),
migrations.AddField(
model_name='citytaggeditem',
......@@ -39,7 +39,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='citytaggeditem',
name='usefull_links',
field=backend.models.tools.jSONField.JSONField(default=list),
field=backend.fields.jSONField.JSONField(default=list),
),
migrations.AddField(
model_name='countrytaggeditem',
......@@ -54,7 +54,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='countrytaggeditem',
name='usefull_links',
field=backend.models.tools.jSONField.JSONField(default=list),
field=backend.fields.jSONField.JSONField(default=list),
),
migrations.AddField(
model_name='universitytaggeditem',
......@@ -69,6 +69,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='universitytaggeditem',
name='usefull_links',
field=backend.models.tools.jSONField.JSONField(default=list),
field=backend.fields.jSONField.JSONField(default=list),
),
]
# Generated by Django 2.0.3 on 2018-09-10 08:16
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0003_auto_20180909_1547'),
]
operations = [
migrations.AlterUniqueTogether(
name='campustaggeditem',
unique_together={('campus', 'tag', 'importance_level')},
),
migrations.AlterUniqueTogether(
name='citytaggeditem',
unique_together={('city', 'tag', 'importance_level')},
),
migrations.AlterUniqueTogether(
name='countrytaggeditem',
unique_together={('country', 'tag', 'importance_level')},
),
migrations.AlterUniqueTogether(
name='universitytaggeditem',
unique_together={('university', 'tag', 'importance_level')},
),
]
from django.db import models
from backend.models.my_model import MyModelVersionned, MyModelVersionnedSerializer, MyModelVersionnedViewSet
from backend.models.tools import JSONField
from backend.models.abstract.my_model import MyModelVersionned, MyModelVersionnedSerializer, MyModelVersionnedViewSet
from backend.fields import JSONField
from backend.validators.tag import validate_content_against_config
from backend.validators.tag.tags_config import USEFULL_LINKS_CONFIG
......
......@@ -7,7 +7,7 @@ from .myModel import MyModel
from .pendingModeration import PendingModerationSerializer
from backend.utils import get_user_level
from backend.permissions import is_moderation_required
from backend.models.tools import MySerializerWithJSON
from backend.custom import MySerializerWithJSON
CLEANED_MY_MODEL_DATA = {
'moderated_by': None,
......
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.signals import new_revision_saved
from rest_framework import serializers, mixins, viewsets
import reversion
......@@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType
from django.core.serializers.base import DeserializationError
from django.core import serializers as djangoSerializers
from backend.utils import get_viewset_permissions
from backend.models.tools import MySerializerWithJSON
from backend.custom import MySerializerWithJSON
class MyModelVersionned(MyModel):
......
from .myModelSerializer import MyModelSerializer
from backend.permissions import DEFAULT_VIEWSET_PERMISSIONS
from backend.models.tools import DictModeViewSet
from backend.custom import DictModeViewSet
class MyModelViewSet(DictModeViewSet):
......
......@@ -2,10 +2,10 @@ from django.db import models
from rest_framework import serializers, viewsets
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from backend.models.tools import JSONField
from backend.fields import JSONField
from django.contrib.auth.models import User
from backend.utils import get_viewset_permissions, get_model_config
from backend.models.tools import MySerializerWithJSON
from backend.custom import MySerializerWithJSON
class PendingModeration(models.Model):
......
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.currency import Currency
from rest_framework import serializers
from django.core.validators import MinValueValidator
......
from .taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet # noqa: F401
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from .tag import Tag
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.tag import Tag
from backend.validators.tag import tagged_item_validation
from backend.models.tools import JSONField
from backend.fields import JSONField
class TaggedItem(BasicModule):
......
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.city import City
from backend.models.university import University
from django.core.validators import MinValueValidator, MaxValueValidator
......
from django.db import models
from backend.models.campus import Campus
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.country import Country
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.city import City
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.utils import get_model_config, get_viewset_permissions
# Data model based on : https://unstats.un.org/unsd/methodology/m49/overview/
......
from django.db import models
from backend.models.country import Country
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.country import Country
from backend.models.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.models.abstract.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.country import Country
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from django.core.validators import MinValueValidator
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.university import University
from backend.models.other_core import Semester, Specialty
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.other_core import Department
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from .tag import Tag, TagSerializer, TagViewSet # noqa: F401
from .taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet # noqa: F401
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.tools import JSONField
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.fields import JSONField
from backend.utils import get_viewset_permissions, get_model_config
......
from django.db import models
from backend.models.my_model import MyModel
from backend.models.abstract.my_model import MyModel
from backend.utils import get_model_config
from django.core.exceptions import ValidationError
from rest_framework.validators import ValidationError as RFValidationError
from backend.validators.tag.url import validate_extension
from django.conf import settings
from backend.models.my_model import MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
......
from django.db import models
from backend.models.university import University
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.university import University
from backend.models.currency import Currency
from django.core.validators import MinValueValidator
......
......@@ -2,7 +2,7 @@ from backend.models.university import University
from backend.models.campus import CampusSerializer
from backend.models.university import UniversityDriSerializer
from backend.models.my_model import MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
......
from django.db import models
from backend.models.university import University
from backend.models.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.models.abstract.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.university import University
from rest_framework import serializers
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.university import University
from backend.utils import get_model_config, get_viewset_permissions
......
......@@ -3,8 +3,8 @@ from backend.models.other_core.specialty import Specialty
from backend.models.other_core.semester import Semester
from backend.models.university import University
from django.contrib.auth.models import User
from backend.models.tools import JSONField
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.fields import JSONField
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
......@@ -3,7 +3,7 @@ from django.core.validators import MaxValueValidator
from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerializer, UserRestrictedModuleViewSet
from backend.models.user import PreviousDeparture
from backend.models.tools import JSONField
from backend.fields import JSONField
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from rest_framework import serializers
from backend.models.university import University
from backend.models.tools import JSONField
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.fields import JSONField
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from django.contrib.auth.models import User
from backend.utils import get_viewset_permissions, get_model_config
......
from django.db import models
from rest_framework import serializers
from django.contrib.auth.models import User
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
class UserRestrictedModule(MyModel):
"""
TODO move to abstract folder ?
"""
# RGPD made easy with CASCADE
owner = models.ForeignKey(User, on_delete=models.CASCADE)
......
from django.test import override_settings
from .withUserTestCase import WithUserTestCase
from backend.models.my_model import ForTestingModeration
from backend.models.my_model import PendingModeration
from backend.models.abstract.my_model import ForTestingModeration
from backend.models.abstract.my_model import PendingModeration
from django.contrib.contenttypes.models import ContentType
from django.conf import settings
from backend.models.university import University
......
from django.test import TestCase
from backend.models.my_model.myModel import validate_obj_model_lv
from backend.models.abstract.my_model.myModel import validate_obj_model_lv
import pytest
from django.core.exceptions import ValidationError
from backend.permissions import OBJ_MODERATION_PERMISSIONS
......
from django.test import TestCase
from backend.models.scholarship import ScholarshipSerializer
from backend.models.abstract.scholarship import ScholarshipSerializer
import pytest
from rest_framework.validators import ValidationError
......
from backend.models.my_model import ForTestingVersioning
from backend.models.abstract.my_model import ForTestingVersioning
from reversion.models import Version
from backend.signals import squashRevisionByUser
import reversion
......
from .withUserTestCase import WithUserTestCase
from backend.models.my_model import ForTestingVersioning
from backend.models.abstract.my_model import ForTestingVersioning
from django.conf import settings
from reversion.models import Version
from backend.signals import new_revision_saved
......
from .is_member import is_member # noqa: F401
from .file import read_file, write_file # noqa: F401
from .find_api_end_point_for_viewset import find_api_end_point_for_viewset # noqa: F401
from .get_model_config import get_model_config # noqa: F401
from .get_viewset_permissions import get_viewset_permissions # noqa: F401
......
def read_file(file):
with open(file, "r") as myfile:
return myfile.read()
def write_file(file, data):
with open(file, 'w') as the_file:
the_file.write(data)
......@@ -224,14 +224,14 @@
- model: PendingModeration
viewset: PendingModerationViewSet
import_location: my_model
import_location: abstract.my_model
api_end_point: pendingModeration
viewset_permission: IsStaff
- model: Version
viewset: VersionViewSet
import_location: my_model
import_location: abstract.my_model
api_end_point: versions
api_attr: (?P<content_type_id>[0-9]+)/(?P<object_pk>[0-9A-Za-z]+)
api_name: versionsList
......@@ -239,14 +239,14 @@
- model: ForTestingModeration
viewset: ForTestingModerationViewSet
import_location: my_model
import_location: abstract.my_model
api_end_point: test/moderation
moderation_level: 1
requires_testing: true
- model: ForTestingVersioning
viewset: ForTestingVersioningViewSet
import_location: my_model
import_location: abstract.my_model
api_end_point: test/versioning
moderation_level: 1
requires_testing: true
......
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