-
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.
Merge branch 'dev' into dependabot/pip/dev/sentry-sdk-2.14.0
- Loading branch information
Showing
37 changed files
with
662 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,7 @@ class Meta: | |
"user_id", | ||
"first_name", | ||
"last_name", | ||
"image", | ||
) | ||
|
||
|
||
|
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.16 on 2024-10-01 06:25 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("forms", "0013_alter_field_type"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="form", | ||
name="description", | ||
field=models.TextField(blank=True, default=""), | ||
), | ||
] |
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 |
---|---|---|
|
@@ -51,6 +51,7 @@ class Meta: | |
fields = ( | ||
"id", | ||
"title", | ||
"description", | ||
"fields", | ||
"template", | ||
"resource_type", | ||
|
Empty file.
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,5 @@ | ||
from django.contrib import admin | ||
|
||
from app.index import models | ||
|
||
admin.site.register(models.Bug) |
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 IndexConfig(AppConfig): | ||
name = "app.index" |
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.db import models | ||
|
||
|
||
class Status(models.TextChoices): | ||
OPEN = "OPEN", "Åpen" | ||
CLOSED = "CLOSED", "Lukket" | ||
IN_PROGRESS = "IN_PROGRESS", "Under arbeid" | ||
REJECTED = "REJECTED", "Avvist" |
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,2 @@ | ||
from app.index.factories.bug_factory import BugFactory | ||
from app.index.factories.idea_factory import IdeaFactory |
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,13 @@ | ||
import factory | ||
from factory.django import DjangoModelFactory | ||
|
||
from app.content.factories import UserFactory | ||
from app.index.models.bug import Bug | ||
|
||
|
||
class BugFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Bug | ||
|
||
title = factory.Sequence(lambda n: f"Bug{n}") | ||
author = factory.SubFactory(UserFactory) |
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,13 @@ | ||
import factory | ||
from factory.django import DjangoModelFactory | ||
|
||
from app.content.factories import UserFactory | ||
from app.index.models.idea import Idea | ||
|
||
|
||
class IdeaFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Idea | ||
|
||
title = factory.Sequence(lambda n: f"Idea{n}") | ||
author = factory.SubFactory(UserFactory) |
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,112 @@ | ||
# Generated by Django 4.2.5 on 2024-09-26 14:54 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("contenttypes", "0002_remove_content_type_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Feedback", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("title", models.CharField(max_length=100)), | ||
("description", models.TextField(blank=True, default="")), | ||
( | ||
"status", | ||
models.CharField( | ||
default="OPEN", | ||
max_length=20, | ||
verbose_name=[ | ||
("OPEN", "Åpen"), | ||
("CLOSED", "Lukket"), | ||
("IN_PROGRESS", "Under arbeid"), | ||
("REJECTED", "Avvist"), | ||
], | ||
), | ||
), | ||
( | ||
"author", | ||
models.ForeignKey( | ||
blank=True, | ||
default=None, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"polymorphic_ctype", | ||
models.ForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="polymorphic_%(app_label)s.%(class)s_set+", | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ("created_at",), | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="Bug", | ||
fields=[ | ||
( | ||
"feedback_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="index.feedback", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("index.feedback",), | ||
), | ||
migrations.CreateModel( | ||
name="Idea", | ||
fields=[ | ||
( | ||
"feedback_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="index.feedback", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("index.feedback",), | ||
), | ||
] |
Empty file.
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 app.index.models.bug import Bug | ||
from app.index.models.feedback import Feedback | ||
from app.index.models.idea import Idea |
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 app.index.models.feedback import Feedback | ||
|
||
|
||
class Bug(Feedback): | ||
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,76 @@ | ||
from django.db import models | ||
|
||
from polymorphic.models import PolymorphicModel | ||
|
||
from app.common.enums import AdminGroup, Groups | ||
from app.common.permissions import BasePermissionModel, check_has_access | ||
from app.content.models.user import User | ||
from app.index.enums import Status | ||
from app.util.models import BaseModel | ||
|
||
|
||
class Feedback(BaseModel, BasePermissionModel, PolymorphicModel): | ||
|
||
read_access = (Groups.TIHLDE,) | ||
write_access = (Groups.TIHLDE,) | ||
|
||
title = models.CharField(max_length=100) | ||
description = models.TextField(default="", blank=True) | ||
|
||
author = models.ForeignKey( | ||
User, blank=True, null=True, default=None, on_delete=models.SET_NULL | ||
) | ||
status = models.CharField(Status.choices, default=Status.OPEN, max_length=20) | ||
|
||
def __str__(self): | ||
return f"{self.title} - {self.status}" | ||
|
||
class Meta: | ||
ordering = ("created_at",) | ||
|
||
@classmethod | ||
def has_read_permission(cls, request): | ||
return super().has_read_permission(request) | ||
|
||
@classmethod | ||
def has_write_permission(cls, request): | ||
return super().has_write_permission(request) | ||
|
||
@classmethod | ||
def has_retrieve_permission(cls, request): | ||
return cls.has_read_permission(request) | ||
|
||
@classmethod | ||
def has_create_permission(cls, request): | ||
return cls.has_write_permission(request) | ||
|
||
@classmethod | ||
def has_update_permission(cls, request): | ||
return cls.has_write_permission(request) | ||
|
||
@classmethod | ||
def has_destroy_permission(cls, request): | ||
return cls.has_write_permission(request) | ||
|
||
@classmethod | ||
def has_list_permission(cls, request): | ||
return cls.has_read_permission(request) | ||
|
||
def has_object_read_permission(self, request): | ||
return self.has_read_permission(request) | ||
|
||
def has_object_write_permission(self, request): | ||
return self.has_write_permission(request) | ||
|
||
def has_object_retrieve_permission(self, request): | ||
return self.has_object_read_permission(request) | ||
|
||
def has_object_update_permission(self, request): | ||
return ( | ||
check_has_access([AdminGroup.INDEX], request) or self.author == request.user | ||
) | ||
|
||
def has_object_destroy_permission(self, request): | ||
return ( | ||
check_has_access([AdminGroup.INDEX], request) or self.author == request.user | ||
) |
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 app.index.models.feedback import Feedback | ||
|
||
|
||
class Idea(Feedback): | ||
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,3 @@ | ||
from app.index.serializers.bug import BugListSerializer | ||
from app.index.serializers.idea import IdeaListSerializer | ||
from app.index.serializers.feedback import FeedbackListPolymorphicSerializer |
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 app.common.serializers import BaseModelSerializer | ||
from app.content.serializers.user import SimpleUserSerializer | ||
from app.index.models.bug import Bug | ||
|
||
|
||
class BugListSerializer(BaseModelSerializer): | ||
author = SimpleUserSerializer(read_only=True) | ||
|
||
class Meta: | ||
model = Bug | ||
fields = ( | ||
"id", | ||
"title", | ||
"status", | ||
"created_at", | ||
"author", | ||
) |
Oops, something went wrong.