Commit 7db3e41d authored by Florent Chehab's avatar Florent Chehab

Merge branch 'feature_moderation' into 'frontend'

Feature moderation

See merge request chehabfl/outgoing_rex!13
parents f1c99e79 1a6bb9ab
Pipeline #26542 passed with stages
in 2 minutes and 49 seconds
[run]
omit = *migrations*
source = .
omit =
*migrations*
tests/*
source = .
[flake8]
# E501 line too long
ignore = E501
exclude = tests/*, env/*
\ No newline at end of file
exclude =
env/*
node_modules/*
......@@ -8,4 +8,5 @@ db.sqlite3
node_modules
.coverage
htmlcov
.vscode
\ No newline at end of file
.vscode
.pytest_cache
......@@ -14,9 +14,7 @@ testing:
- export DATABASE_URL=postgres://postgres:@postgres:5432/python-test-app
- pip install -r requirements.txt --quiet
- ./manage.py check
- coverage3 run manage.py test
- coverage3 report
- coverage3 html
- pytest -n 4 general/ frontend/ backend/ --cov-report html
artifacts:
paths:
- htmlcov/
......
......@@ -8,7 +8,9 @@
"**/.DS_Store": true,
"**/__pycache__":true,
"**/*.pyc":true,
"htmlcov":true
"htmlcov":false,
"env":true,
".coverage":true
},
"cSpell.language": "en,fr-FR,fr",
"python.linting.flake8Enabled": true
......
......@@ -47,6 +47,8 @@ from backend.models.user import PreviousDeparture
from backend.models.user import PreviousDepartureFeedback
from backend.models.user import UserData
from backend.models.my_model import PendingModeration
CLASSIC_MODELS = [
Country,
City,
......@@ -59,7 +61,8 @@ CLASSIC_MODELS = [
RecommendationList,
PreviousDeparture,
PreviousDepartureFeedback,
UserData
UserData,
PendingModeration
]
VERSIONNED_MODELS = [
......
# Generated by Django 2.0.3 on 2018-08-24 13:51
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),
('contenttypes', '0002_remove_content_type_name'),
('backend', '0003_auto_20180824_1011'),
]
operations = [
migrations.CreateModel(
name='PendingModeration',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.CharField(max_length=100)),
('content_object', django.contrib.postgres.fields.jsonb.JSONField()),
('delete', models.NullBooleanField(default=None)),
('approve', models.NullBooleanField(default=None)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
),
]
# Generated by Django 2.0.3 on 2018-08-24 13:53
import django.contrib.postgres.fields.jsonb
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0004_pendingmoderation'),
]
operations = [
migrations.AlterField(
model_name='pendingmoderation',
name='content_object',
field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
),
]
# Generated by Django 2.0.3 on 2018-08-24 13:58
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0005_auto_20180824_1553'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='content_object',
new_name='new_object',
),
]
# Generated by Django 2.0.3 on 2018-08-24 15:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0006_auto_20180824_1558'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='new_object',
new_name='object_to_moderate',
),
]
# Generated by Django 2.0.3 on 2018-08-24 19:28
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('backend', '0007_auto_20180824_1741'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='object_to_moderate',
new_name='new_object',
),
migrations.RemoveField(
model_name='pendingmoderation',
name='approve',
),
migrations.RemoveField(
model_name='pendingmoderation',
name='delete',
),
migrations.RemoveField(
model_name='university',
name='updated_at',
),
migrations.AddField(
model_name='university',
name='moderated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='moderated', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='university',
name='moderated_on',
field=models.DateTimeField(null=True),
),
migrations.AddField(
model_name='university',
name='updated_on',
field=models.DateTimeField(null=True),
),
migrations.AlterField(
model_name='campus',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campusaccommodation',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campuscultureandstudentlife',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campusotherstuff',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campustransport',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='cityotherstuff',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='cityphoto',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='citytourism',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='citytransport',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryculture',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countrydri',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryhealthinsurance',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryotherinsurance',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryotherstuff',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryphoto',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryscholarship',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countrytourism',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countrytransport',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='countryvisaadministrative',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='university',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='updated', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universitycourses',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityculture',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universitydri',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityinfo',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityinsurance',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityotherstuff',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityphoto',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityscholarship',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universitysemestersdates',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='universityspecialoffer',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 2.0.3 on 2018-08-24 20:18
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('backend', '0008_auto_20180824_2128'),
]
operations = [
migrations.AlterUniqueTogether(
name='pendingmoderation',
unique_together={('content_type', 'object_id')},
),
]
# Generated by Django 2.0.3 on 2018-08-24 20:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0009_auto_20180824_2218'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='author',
new_name='updated_by',
),
migrations.AddField(
model_name='pendingmoderation',
name='updated_on',
field=models.DateTimeField(null=True),
),
]
# Generated by Django 2.0.3 on 2018-08-25 16:49
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('backend', '0010_auto_20180824_2251'),
]
operations = [
migrations.CreateModel(
name='TestingModeration',
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)),
('do_not_touch_this_stuff', models.CharField(max_length=100)),
('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,
},
),
migrations.AlterField(
model_name='university',
name='moderated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='university',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 2.0.3 on 2018-08-25 17:38
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('backend', '0011_auto_20180825_1849'),
]
operations = [
migrations.RenameModel(
old_name='TestingModeration',
new_name='ForTestingModeration',
),
]
# Generated by Django 2.0.3 on 2018-08-25 17:44
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0012_auto_20180825_1938'),
]
operations = [
migrations.RenameField(
model_name='fortestingmoderation',
old_name='do_not_touch_this_stuff',
new_name='aaa',
),
]
# Generated by Django 2.0.3 on 2018-08-26 08:48
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('backend', '0013_auto_20180825_1944'),
]
operations = [
migrations.CreateModel(
name='ForTestingVersionning',
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)),
('aaa', models.CharField(max_length=100)),
('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-26 09:27
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0014_fortestingversionning'),
]
operations = [
migrations.RenameField(
model_name='fortestingversionning',
old_name='aaa',
new_name='bbb',
),
]
This diff is collapsed.
from django.db import models
from rest_framework import serializers, permissions
from backend.models.tools import DictModeViewSet
from rest_framework import serializers
from backend.models.location import Country
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
# Data model based on : https://unstats.un.org/unsd/methodology/m49/overview/
class City(models.Model):
class City(MyModel):
name = models.CharField(max_length=200)
local_name = models.CharField(max_length=200, null=True, blank=True)
# We add an area to distinguish similarly named cities
......@@ -21,7 +18,7 @@ API RELATED STUFF BELLOW
"""
class CitySerializer(serializers.ModelSerializer):
class CitySerializer(MyModelSerializer):
country_url = serializers.SerializerMethodField()
def get_country_url(self, obj):
......@@ -36,7 +33,6 @@ class CitySerializer(serializers.ModelSerializer):
fields = '__all__'
class CityViewSet(DictModeViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
class CityViewSet(MyModelVersionnedViewSet):
queryset = City.objects.all() # pylint: disable=E1101
serializer_class = CitySerializer
from django.db import models
from backend.models.module import BasicModule
from backend.models.module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.location import City
from rest_framework import viewsets, permissions
from backend.models.module import BasicModuleSerializer
####################
......@@ -20,8 +18,8 @@ class CityTransportSerializer(BasicModuleSerializer):
fields = '__all__'
class CityTransportViewSet(viewsets.ModelViewSet): # TODO switch to dict
permission_classes = (permissions.DjangoModelPermissions,)
class CityTransportViewSet(BasicModuleViewSet):
queryset = CityTransport.objects.all() # pylint: disable=E1101
serializer_class = CityTransportSerializer
......@@ -45,8 +43,8 @@ class CityTourismSerializer(BasicModuleSerializer):
fields = '__all__'
class CityTourismViewSet(viewsets.ModelViewSet): # TODO switch to dict
permission_classes = (permissions.DjangoModelPermissions,)
class CityTourismViewSet(BasicModuleViewSet):
queryset = CityTourism.objects.all() # pylint: disable=E1101
serializer_class = CityTourismSerializer
......@@ -70,8 +68,7 @@ class CityOtherStuffSerializer(BasicModuleSerializer):
fields = '__all__'
# TODO switch to dict
class CityOtherStuffViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
class CityOtherStuffViewSet(BasicModuleViewSet):
queryset = CityOtherStuff.objects.all() # pylint: disable=E1101
serializer_class = CityOtherStuffSerializer
from django.db import models
from backend.models.location import City
from backend.models.module import VersionnedModuleSerializer
from backend.models.module import Photo
from rest_framework import viewsets, permissions
from backend.models.module import Photo, PhotoSerializer, PhotoViewSet
class CityPhoto(Photo):
......@@ -16,14 +14,13 @@ class CityPhoto(Photo):
unique_together = ('city', 'photo')
class CityPhotoSerializer(VersionnedModuleSerializer):
class CityPhotoSerializer(PhotoSerializer):
class Meta:
model = CityPhoto
fields = '__all__'
class CityPhotoViewSet(viewsets.ModelViewSet): # TODO switch to dict
permission_classes = (permissions.DjangoModelPermissions,)
class CityPhotoViewSet(PhotoViewSet):
queryset = CityPhoto.objects.all() # pylint: disable=E1101
serializer_class = CityPhotoSerializer
from django.db import models
from rest_framework import serializers, permissions
from backend.models.tools import DictModeViewSet
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
# Data model based on : https://unstats.un.org/unsd/methodology/m49/overview/
class Country(models.Model):
class Country(MyModel):
name = models.CharField(max_length=200)
iso_alpha2_code = models.CharField(primary_key=True, max_length=2)
iso_alpha3_code = models.CharField(
......@@ -20,19 +19,13 @@ class Country(models.Model):
max_length=3, null=True, blank=True)
"""
API RELATED STUFF BELLOW
"""
class CountrySerializer(serializers.ModelSerializer):
class CountrySerializer(MyModelSerializer):
class Meta:
model = Country
fields = '__all__'
class CountryViewSet(DictModeViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
class CountryViewSet(MyModelVersionnedViewSet):
queryset = Country.objects.all() # pylint: disable=E1101
serializer_class = CountrySerializer
from django.db import models
from backend.models.module import BasicModule