-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added model, serializer and viewset for model News Reaction
- Loading branch information
Showing
5 changed files
with
49 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.0.8 on 2023-09-26 16:11 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('content', '0053_news_emojis_allowed_news_reactions'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='news', | ||
name='reactions', | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.db import models | ||
|
||
from app.common.enums import Groups | ||
from app.common.permissions import BasePermissionModel | ||
from app.content.models.news import News | ||
from app.emoji.models.reaction import Reaction | ||
from app.util.models import BaseModel | ||
|
||
|
||
class NewsReaction(BaseModel, BasePermissionModel): | ||
reaction = models.ForeignKey(Reaction, on_delete=models.CASCADE) | ||
news = models.ForeignKey(News, on_delete=models.CASCADE) | ||
|
||
write_access = [Groups.TIHLDE] | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint( | ||
fields=["reaction", "news"], name="unique together: reaction and news" | ||
) | ||
] |
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,11 @@ | ||
from app.common.serializers import BaseModelSerializer | ||
from app.emoji.models.news_reaction import NewsReaction | ||
|
||
|
||
class UserNewsReactionSerializer(BaseModelSerializer): | ||
class Meta: | ||
model = NewsReaction | ||
fields = ( | ||
"reaction", | ||
"news", | ||
) |
Empty file.