-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
750 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class RouletteIntegrationConfig(AppConfig): | ||
name = 'roulette_integration' |
34 changes: 34 additions & 0 deletions
34
osmchadjango/roulette_integration/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 2.2.11 on 2020-06-01 01:08 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('changeset', '0050_auto_20181008_1001'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ChallengeIntegration', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('challenge_id', models.IntegerField(db_index=True, unique=True)), | ||
('active', models.BooleanField(db_index=True, default=True)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
('reasons', models.ManyToManyField(related_name='challenges', to='changeset.SuspicionReasons')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='challenges', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'verbose_name': 'Challenge Integration', | ||
'verbose_name_plural': 'Challenge Integrations', | ||
'ordering': ['id'], | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
from django.contrib.auth import get_user_model | ||
|
||
from ..changeset.models import SuspicionReasons | ||
|
||
User = get_user_model() | ||
|
||
|
||
class ChallengeIntegration(models.Model): | ||
challenge_id = models.IntegerField(unique=True, db_index=True) | ||
reasons = models.ManyToManyField(SuspicionReasons, related_name='challenges') | ||
active = models.BooleanField(default=True, db_index=True) | ||
created = models.DateTimeField(auto_now_add=True) | ||
user = models.ForeignKey(User, related_name="challenges", on_delete=models.CASCADE) | ||
|
||
def __str__(self): | ||
return 'Challenge {}'.format(self.challenge_id) | ||
|
||
class Meta: | ||
ordering = ['id'] | ||
verbose_name = 'Challenge Integration' | ||
verbose_name_plural = 'Challenge Integrations' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from rest_framework.fields import HiddenField, CurrentUserDefault, ReadOnlyField | ||
from rest_framework.serializers import ModelSerializer, PrimaryKeyRelatedField | ||
|
||
from ..changeset.serializers import SuspicionReasonsSerializer | ||
from .models import ChallengeIntegration | ||
|
||
|
||
class ChallengeIntegrationSerializer(ModelSerializer): | ||
user = HiddenField(default=CurrentUserDefault()) | ||
owner = ReadOnlyField(source='user.username', default=None) | ||
|
||
# def create(self, validated_data): | ||
# import ipdb; ipdb.set_trace() | ||
# reasons_data = [i.get('id') for i in validated_data.pop('reasons')] | ||
# obj = ChallengeIntegration.objects.create(**validated_data) | ||
|
||
class Meta: | ||
model = ChallengeIntegration | ||
fields = ['id', 'challenge_id', 'reasons', 'user', 'active', 'created', 'owner'] | ||
read_only_fields = ('created', 'owner') |
Empty file.
Oops, something went wrong.