-
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 emoji dependency * created emoji app * removed unused files * added emoji models, serializers and views * added urls for emoji app * fixed models and added basic admin * added view for unicode emojis * ever closer to the end * fixed emoji serializers * fixed model admin * is ready? * added comment for empty method * removed type from str in CustomShortName * ran make pr * Started developing UserNewsReaction * Finished model and serializer. Created factory and started testing * Added pytest.fixture for emoji and added it to test * Finished tests for UserNewsReaction * Removed unsused code and comments * Removed line spacings * ready for merging main into this branch * fixed linting * Changed read_access on reactions to only be members * made news_emoji model, serializer and viewset * added new tests and created a news-emoji factory * Added realated names to news emojis and reactions * Fixed some linting * Added related name to reactions in news * Added tests for both news reactions and toddel reactions and modified reactions so that they have to be allowed on a specific news or toddel * Fixed test failures and added url support to reactions for toddel * Changed changelog * Removed potential cross-site scripting * Removed remainding potential cross-site scripting * Refactured emoji backend and implemented reactions for unicode emojis * Added a endpoint for retrieving if emojis is allowed on a news * Cleaned up some code * Added forgot import * Fixed a bug * Simplified the feature * Added model, serializer and viewset for model News Reaction * Made reactions use generic foreignkeys and added support for reactions to news * Made tests for post and put a reaction on news and modyfied it so they pass * Removed commented out code * Fixed some bugs where content_type was not saved * Modified the Reaction serializer and made a create and update serializer * Cleaned up init files and simplyfied migrations * Fixed conflict after merging dev * Made enum for content types and removed unused code * Updated update serializer to use the update method instead of create * Modified tests and fixed update for reaction * Made requested changes and added a test for changing other users reactions and made it pass * Made requested changes * Linting error from dev * Fixed error from merging of dev * Added a check so that a user can't create a reaction for another user * cleanup * fixed migration error * Added reactions to event * Removed unintential code * added emojis_allowed for update and create serializer for event * Removed unused code and linted * added user information to reaction serializer --------- Co-authored-by: Harry Linrui Xu <[email protected]> Co-authored-by: Harry Linrui Xu <[email protected]> Co-authored-by: Tobias Rødahl Thingnes <[email protected]> Co-authored-by: Jarand Romestrand <[email protected]> Co-authored-by: Tini Tran <[email protected]> Co-authored-by: JarandJR <[email protected]> Co-authored-by: Mads Nylund <[email protected]> Co-authored-by: Mads Nylund <[email protected]>
- Loading branch information
1 parent
b9af21f
commit 0c7853f
Showing
35 changed files
with
589 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.5 on 2023-10-17 22:09 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("content", "0053_event_contact_person"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="news", | ||
name="emojis_allowed", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
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
23 changes: 0 additions & 23 deletions
23
app/content/migrations/0055_remove_qrcode_url_qrcode_content.py
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
# Generated by Django 4.2.5 on 2023-11-16 20:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("content", "0056_registration_created_by_admin"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="event", | ||
name="emojis_allowed", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
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
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,8 @@ | ||
from django.contrib import admin | ||
|
||
from app.emoji.models.reaction import Reaction | ||
|
||
|
||
@admin.register(Reaction) | ||
class ReactionAdmin(admin.ModelAdmin): | ||
pass |
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 EmojiConfig(AppConfig): | ||
name = "app.emoji" |
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,6 @@ | ||
from django.db import models | ||
|
||
|
||
class ContentTypes(models.TextChoices): | ||
NEWS = "news" | ||
EVENT = "event" |
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 @@ | ||
from rest_framework import status | ||
from rest_framework.exceptions import APIException | ||
|
||
|
||
class APIReactionNotAllowedException(APIException): | ||
status_code = status.HTTP_403_FORBIDDEN | ||
default_detail = "Reaksjoner er ikke tillatt her" | ||
|
||
|
||
class APIContentTypeNotSupportedException(APIException): | ||
status_code = status.HTTP_400_BAD_REQUEST | ||
default_detail = "Er ikke støtte for denne typen" | ||
|
||
|
||
class APIReactionDuplicateNotAllowedException(APIException): | ||
status_code = status.HTTP_400_BAD_REQUEST | ||
default_detail = "Du har allerede reagert her" |
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,37 @@ | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
import factory | ||
from factory.django import DjangoModelFactory | ||
|
||
from app.content.factories.event_factory import EventFactory | ||
from app.content.factories.news_factory import NewsFactory | ||
from app.content.factories.user_factory import UserFactory | ||
from app.content.models.event import Event | ||
from app.content.models.news import News | ||
from app.emoji.models.reaction import Reaction | ||
|
||
|
||
class NewsReactionFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Reaction | ||
|
||
emoji = factory.Faker("emoji") | ||
user = factory.SubFactory(UserFactory) | ||
content_object = factory.SubFactory(NewsFactory) | ||
|
||
@factory.lazy_attribute | ||
def content_type(self): | ||
return ContentType.objects.get_for_model(News) | ||
|
||
|
||
class EventReactionFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Reaction | ||
|
||
emoji = factory.Faker("emoji") | ||
user = factory.SubFactory(UserFactory) | ||
content_object = factory.SubFactory(EventFactory) | ||
|
||
@factory.lazy_attribute | ||
def content_type(self): | ||
return ContentType.objects.get_for_model(Event) |
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,53 @@ | ||
# Generated by Django 4.2.5 on 2023-11-18 16:13 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("contenttypes", "0002_remove_content_type_name"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Reaction", | ||
fields=[ | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"reaction_id", | ||
models.AutoField(editable=False, primary_key=True, serialize=False), | ||
), | ||
("emoji", models.CharField(max_length=60)), | ||
("object_id", models.PositiveIntegerField(blank=True, null=True)), | ||
( | ||
"content_type", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="reactions", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Reaction", | ||
"verbose_name_plural": "Reactions", | ||
"unique_together": {("user", "object_id", "content_type")}, | ||
}, | ||
), | ||
] |
Empty file.
Empty file.
Oops, something went wrong.