Skip to content
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

Add feedback model #111

Merged
merged 9 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def init_with_context(self, context):
"mod_app.models.teaching_analysis_models.*",
"mod_app.models.bibliography_model.*",
"mod_app.models.project_note_model.ProjectNote",
"mod_app.models.feedback_model.Feedback",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be under the "Extras" section. It also doesn't show up since we do actually have to register it in the admin (I was wrong)
You can add it to admin/note_admin.py and use the ProjectNoteAdmin as a template

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, thanks!

),
),
modules.ModelList(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Generated by Django 4.2.5 on 2024-06-27 13:55

import ckeditor.fields
import ckeditor_uploader.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("mod_app", "0022_bibliographyitem_annotation"),
]

operations = [
migrations.AlterField(
model_name="bibliographyitem",
name="full_citation",
field=ckeditor.fields.RichTextField(
help_text="Please use Harvard reference list style. Examples: Author surname, initial. (year). 'Title of article/book/website/photograph'. Available at: URL or DOI where applicable (date accessed). Please note that the website or photo title should be italicised. For more detailed information and examples visit: https://www5.open.ac.uk/library/referencing-and-plagiarism/quick-guide-to-harvard-referencing-cite-them-right",
null=True,
),
),
migrations.AlterField(
model_name="bibliographyitem",
name="short_citation",
field=models.CharField(
help_text="Please use Harvard in-text citation style. Examples: (Author surname, year), or in the case of up to 3 authors: (Author 1 surname, Author 2 surname, Author 3 surname, year), or in the case or more than 3 authors: (Author 1 surname, et al., year) ",
max_length=200,
null=True,
),
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these look the same as

migrations.AlterField(
model_name="bibliographyitem",
name="full_citation",
field=ckeditor.fields.RichTextField(
help_text="Please use Harvard reference list style. Examples: Author surname, initial. (year). 'Title of article/book/website/photograph'. Available at: URL or DOI where applicable (date accessed). Please note that the website or photo title should be italicised. For more detailed information and examples visit: https://www5.open.ac.uk/library/referencing-and-plagiarism/quick-guide-to-harvard-referencing-cite-them-right",
null=True,
),
),
migrations.AlterField(
model_name="bibliographyitem",
name="short_citation",
field=models.CharField(
help_text="Please use Harvard in-text citation style. Examples: (Author surname, year), or in the case of up to 3 authors: (Author 1 surname, Author 2 surname, Author 3 surname, year), or in the case or more than 3 authors: (Author 1 surname, et al., year) ",
max_length=200,
null=True,
),
),

However, the previous migrations include two spaces after full stops whereas the new migrations have a single space

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah we might need to do something with linting then? We have some set up but maybe they need to be more strict

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a check in CI to make sure there are no missing migrations:

python manage.py makemigrations --check --dry-run --no-input

which I think would fail if there are any migrations missing. If this runs on every PR then it should help avoid merging anything with missing migrations

migrations.AlterField(
model_name="film",
name="format_type",
field=models.CharField(
choices=[
("16", "16 mm"),
("70", "70 mm"),
("other", "Other"),
("9.5", "9.5 mm"),
("35", "35 mm"),
],
default="35",
max_length=5,
verbose_name="format",
),
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this field changes every time python manage.py makemigrations is ran. I've opened an issue (#112) and will submit a PR to fix it once this is merged

migrations.AlterField(
model_name="projectnote",
name="bibliography",
field=models.ManyToManyField(
blank=True,
help_text="This field updates on save, and some items may not be visible immediately",
related_name="project_notes",
to="mod_app.bibliographyitem",
),
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks similar to the migration from when the model was created:

(
"bibliography",
models.ManyToManyField(
blank=True,
help_text="This field updates on save, and some items may not be visible immediately",
related_name="project_note",
to="mod_app.bibliographyitem",
),
),

but the related_name has changed from project_note to project_notes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the model definition and the migration differ, I've pushed a fix to change the version on the model since that's more straightforward than fixing previous migrations

migrations.CreateModel(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything before this in the operations should probably be deleted since they should've been covered in earlier migrations, unsure why it keeps doing this.
Should probably rename the file to something like "0023_add_feedback_model.py"
Otherwise all looks good

name="Feedback",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=255)),
(
"content",
ckeditor_uploader.fields.RichTextUploadingField(
blank=True, help_text="Mentions are available here.", null=True
),
),
(
"bibliography",
models.ManyToManyField(
blank=True,
help_text="This field updates on save, and some items may not be visible immediately",
related_name="feedback",
to="mod_app.bibliographyitem",
),
),
],
options={
"verbose_name": "Feedback",
},
),
]
2 changes: 2 additions & 0 deletions mod_app/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .film_model import Film
from .bibliography_model import BibliographyItem
from .project_note_model import ProjectNote
from .feedback_model import Feedback
from .support_models import (
BaseLinkModel,
FileLink,
Expand Down Expand Up @@ -44,4 +45,5 @@
"OtherLink",
"Video",
"ProjectNote",
"Feedback",
]
33 changes: 33 additions & 0 deletions mod_app/models/feedback_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from ckeditor_uploader.fields import RichTextUploadingField
from django.db import models

from .bibliography_model import BibliographyItem
from ..utils.extract_citations import update_bibliography


class Feedback(models.Model):
class Meta:
verbose_name = "Feedback"

def __str__(self):
return self.title

title = models.CharField(max_length=255, null=False)

content = RichTextUploadingField(
null=True,
blank=True,
help_text="Mentions are available here.",
)

bibliography = models.ManyToManyField(
BibliographyItem,
blank=True,
related_name="feedback",
help_text="This field updates on save, and some items may not be visible immediately",
)

def save(self, *args, **kwargs):
super().save(*args, **kwargs)

update_bibliography(self, self.content)
Loading