Commit 04274a84 authored by Florent Chehab's avatar Florent Chehab
Browse files

Fiexs related name causing issues

parent 33e04208
# 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),
),
]
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from rest_framework import serializers # from rest_framework import serializers
# from backend.signals import new_revision_saved # from backend.signals import new_revision_saved
# import reversion # 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): class MyModel(models.Model):
...@@ -18,12 +14,12 @@ class MyModel(models.Model): ...@@ -18,12 +14,12 @@ class MyModel(models.Model):
""" """
moderated_by = models.ForeignKey( moderated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='moderated') User, null=True, on_delete=models.SET_NULL, related_name='+')
moderated_on = models.DateTimeField(null=True) moderated_on = models.DateTimeField(null=True)
updated_on = models.DateTimeField(null=True) updated_on = models.DateTimeField(null=True)
updated_by = models.ForeignKey( updated_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name='updated') User, null=True, on_delete=models.SET_NULL, related_name='+')
class Meta: class Meta:
abstract = True abstract = True
......
from django.db import models
from django.contrib.auth.models import User
from rest_framework import serializers from rest_framework import serializers
from django.utils import timezone from django.utils import timezone
from backend.models.tools import PendingModeration from .pendingModeration import PendingModeration
from django.conf import settings from django.conf import settings
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from backend.utils import is_member
from django.db import models
from .myModel import MyModel from .myModel import MyModel
...@@ -37,10 +36,7 @@ class MyModelSerializer(serializers.ModelSerializer): ...@@ -37,10 +36,7 @@ class MyModelSerializer(serializers.ModelSerializer):
if settings.MODERATION_ACTIVATED: if settings.MODERATION_ACTIVATED:
if request.method in ['POST', 'PUT']: # should be always the case if request.method in ['POST', 'PUT']: # should be always the case
if is_member('Moderator', request.user): return not is_member('Moderators', request.user)
return False
else:
return True
return False return False
......
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