Commit 5ded69c8 authored by Florent Chehab's avatar Florent Chehab

Tag model added

parent b8511f0e
......@@ -6,11 +6,12 @@
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/__pycache__":true,
"**/*.pyc":true,
"htmlcov":false,
"env":true,
".coverage":true
"**/__pycache__": true,
"**/*.pyc": true,
"htmlcov": false,
"env": true,
".coverage": true,
".pytest_cache": true,
},
"cSpell.language": "en,fr-FR,fr",
"python.linting.flake8Enabled": true
......
......@@ -50,6 +50,8 @@ from backend.models.user import PreviousDepartureFeedback
from backend.models.user import UserData
from backend.models.my_model import PendingModeration
from backend.models.module import Tag
CLASSIC_MODELS = [
Country,
......@@ -65,7 +67,8 @@ CLASSIC_MODELS = [
PreviousDeparture,
PreviousDepartureFeedback,
UserData,
PendingModeration
PendingModeration,
Tag
]
VERSIONNED_MODELS = [
......
- model: Tag
viewset: TagViewSet
import_location: module
api_end_point: tag
- model: Country
viewset: CountryViewSet
import_location: location
......
# Generated by Django 2.0.3 on 2018-08-29 16:06
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('backend', '0021_auto_20180828_2128'),
]
operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('moderated_on', models.DateTimeField(null=True)),
('updated_on', models.DateTimeField(null=True)),
('name', models.CharField(max_length=100)),
('config', django.contrib.postgres.fields.jsonb.JSONField()),
('moderated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]
# Generated by Django 2.0.3 on 2018-08-29 16:15
import django.contrib.postgres.fields.jsonb
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0022_tag'),
]
operations = [
migrations.AlterField(
model_name='tag',
name='config',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict),
),
]
......@@ -3,4 +3,4 @@ from .scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from .photo import Photo, PhotoSerializer, PhotoViewSet # noqa: F401
from .driRestrictedModule import DriRestrictedModule, DriRestrictedModuleSerializer, DriRestrictedModuleViewSet # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
# MyModelVersionned, MyModelVersionnedSerializer # noqa: F401
from .tag import Tag, TagSerializer, TagViewSet # noqa: F401
from django.db import models
from rest_framework import permissions
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.tools import IsAdminOrReadOnly
from django.contrib.postgres.fields import JSONField
class Tag(MyModel):
"""
TODO description
"""
name = models.CharField(max_length=100)
config = JSONField(blank=True, default=dict)
class TagSerializer(MyModelSerializer):
class Meta:
model = Tag
fields = '__all__'
class TagViewSet(MyModelViewSet):
permission_classes = (
permissions.IsAuthenticated,
IsAdminOrReadOnly
)
queryset = Tag.objects.all() # pylint: disable=E1101
serializer_class = TagSerializer
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