-
Notifications
You must be signed in to change notification settings - Fork 0
Notifications #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notifications #17
Changes from all commits
9773ee0
bf0d5dc
2e513bc
43fb80b
621623a
b739379
722f8c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 00:41 | ||
| from __future__ import unicode_literals | ||
|
|
||
| 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), | ||
| ('api', '0003_task_done'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='Notification', | ||
| fields=[ | ||
| ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('published_date', models.DateField(verbose_name='Published date')), | ||
| ('modification_date', models.DateField(blank=True, null=True, verbose_name='Modification Date')), | ||
| ('status', models.IntegerField(default=1, verbose_name='Status')), | ||
| ('target_type', models.CharField(max_length=50, verbose_name='Target type')), | ||
| ('target_id', models.PositiveIntegerField(verbose_name='Target ID')), | ||
| ('target_intention', models.CharField(max_length=50, verbose_name='Target intention')), | ||
| ('title', models.CharField(max_length=255, verbose_name='Title')), | ||
| ('text', models.TextField(verbose_name='Text')), | ||
| ('receiver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications_received', to=settings.AUTH_USER_MODEL, verbose_name='Receiver')), | ||
| ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notification_sent', to=settings.AUTH_USER_MODEL, verbose_name='Sender')), | ||
| ], | ||
| options={ | ||
| 'verbose_name_plural': 'Notifications', | ||
| }, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 01:34 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0004_notification'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='notification', | ||
| name='is_read', | ||
| field=models.BooleanField(default=0, verbose_name='Is read'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 03:03 | ||
| from __future__ import unicode_literals | ||
|
|
||
| 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), | ||
| ('api', '0005_notification_is_read'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='task', | ||
| name='created_by', | ||
| field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='task_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'), | ||
| preserve_default=False, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 03:50 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0006_task_created_by'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='task', | ||
| name='created_by', | ||
| field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='task_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 03:51 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0007_auto_20170323_0350'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='task', | ||
| name='created_by', | ||
| field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, related_name='task_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'), | ||
| preserve_default=False, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 03:52 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0008_auto_20170323_0351'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='task', | ||
| name='created_by', | ||
| field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='task_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.10 on 2017-03-23 03:53 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0009_auto_20170323_0352'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='task', | ||
| name='created_by', | ||
| field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, related_name='task_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'), | ||
| preserve_default=False, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,15 @@ class Meta: | |
|
|
||
| labels = BaseLabelSerializer(many=True, read_only=True) | ||
|
|
||
| created_by = UserSerializer(read_only=True) | ||
| created_by_id = serializers.PrimaryKeyRelatedField( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to remove this field in the serializer and just put the actual user in the For the moment i can call the API to say the creator is an other guy because the PS: I think we can made this population of the field in the serializer with the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The create function requires the context to have the logged in user. Instead, In my new commit, I enforce the user inside the view class. |
||
| queryset=models.User.objects.all(), | ||
| source='created_by', | ||
| write_only=True, | ||
| required=False, | ||
| allow_null=True | ||
| ) | ||
|
|
||
| assigned = UserSerializer(read_only=True) | ||
| assigned_id = serializers.PrimaryKeyRelatedField( | ||
| queryset=models.User.objects.all(), | ||
|
|
@@ -189,6 +198,27 @@ class Meta: | |
| ) | ||
|
|
||
|
|
||
| class NotificationSerializer(serializers.ModelSerializer): | ||
|
|
||
| class Meta: | ||
| model = models.Notification | ||
| fields = '__all__' | ||
|
|
||
| sender = UserSerializer(read_only=True) | ||
| sender_id = serializers.PrimaryKeyRelatedField( | ||
| queryset=models.User.objects.all(), | ||
| source='sender', | ||
| write_only=True | ||
| ) | ||
|
|
||
| receiver = UserSerializer(read_only=True) | ||
| receiver_id = serializers.PrimaryKeyRelatedField( | ||
| queryset=models.User.objects.all(), | ||
| source='receiver', | ||
| write_only=True | ||
| ) | ||
|
|
||
|
|
||
| class FileSerializer(serializers.ModelSerializer): | ||
|
|
||
| class Meta: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure with this line. I think it may be good to have this field required.