Skip to content

Commit

Permalink
Remove unneeded submission tagging form
Browse files Browse the repository at this point in the history
Submission tags are created through the inspect submission
UI so the form is unnecessary, as well as the associated
template. Also checked submission tagging add- and delete
forms to verify the tag comes from the accessed course
instance.
  • Loading branch information
murhum1 authored and mikaelGusse committed May 24, 2024
1 parent 569b3bc commit 5777ef5
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 76 deletions.
14 changes: 0 additions & 14 deletions edit_course/course_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from course.models import LearningObjectCategory, CourseModule, CourseInstance, UserTag, SubmissionTag
from course.sis import get_sis_configuration, StudentInfoSystem
from exercise.models import CourseChapter
from exercise.submission_models import SubmissionTagging
from lib.validators import generate_url_key_validator
from lib.fields import UsersSearchSelectField
from lib.widgets import DateTimeLocalInput
Expand Down Expand Up @@ -444,19 +443,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.fields['user'].queryset = course_instance.get_student_profiles()


class SubmissionTaggingForm(forms.ModelForm):
class Meta(ColorTagForm.Meta):
model = SubmissionTagging
fields = [
'tag',
'submission',
]
labels = {
'tag': _('LABEL_SUBMISSION_TAG'),
'submission': _('LABEL_SUBMISSION'),
}


class GitmanagerForm(forms.Form):
key = forms.SlugField(
label=_('LABEL_KEY'),
Expand Down
28 changes: 0 additions & 28 deletions edit_course/templates/edit_course/submissiontagging_add.html

This file was deleted.

28 changes: 4 additions & 24 deletions exercise/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.decorators.csrf import csrf_exempt
from django.db import DatabaseError
from django.views.generic import CreateView

from authorization.permissions import ACCESS
from course.models import CourseModule, SubmissionTag
from course.viewbase import CourseInstanceBaseView, EnrollableViewMixin
from edit_course.course_forms import SubmissionTaggingForm
from edit_course.views import SubmissionTagMixin
from lib.helpers import query_dict_to_list_of_tuples, safe_file_name, is_ajax
from lib.remote_page import RemotePageNotFound, request_for_response
from lib.viewbase import BaseRedirectMixin, BaseView
Expand Down Expand Up @@ -46,11 +43,7 @@ class TableOfContentsView(CourseInstanceBaseView):
class ResultsView(TableOfContentsView):
template_name = "exercise/results.html"


class SubmissionTaggingAddView(SubmissionTagMixin, CreateView):
form_class = SubmissionTaggingForm
template_name = "edit_course/submissiontagging_add.html"
pk_url_kwarg = "subtag_id"
class SubmissionTaggingAddView(CourseInstanceBaseView):
access_mode = ACCESS.ASSISTANT

def post(self, request, *args, **kwargs):
Expand All @@ -59,23 +52,16 @@ def post(self, request, *args, **kwargs):

# Get the Submission and SubTag objects using these ids
submission = Submission.objects.get(id=submission_id)
subtag = SubmissionTag.objects.get(id=subtag_id)
subtag = SubmissionTag.objects.get(id=subtag_id, course_instance=self.instance)

# Create a new SubmissionTagging object
SubmissionTagging.objects.create(submission=submission, tag=subtag)

# Redirect back to the previous page
return redirect(request.META.get('HTTP_REFERER', '/'))

def __init__(self, *args, **kwargs):
self.instance = kwargs.pop('instance', None)
super().__init__(*args, **kwargs)


class SubmissionTaggingRemoveView(SubmissionTagMixin, CreateView):
form_class = SubmissionTaggingForm
template_name = "edit_course/submissiontagging_add.html"
pk_url_kwarg = "subtag_id"
class SubmissionTaggingRemoveView(CourseInstanceBaseView):
access_mode = ACCESS.ASSISTANT

def post(self, request, *args, **kwargs):
Expand All @@ -84,24 +70,18 @@ def post(self, request, *args, **kwargs):

# Get the Submission and SubTag objects using these ids
submission = Submission.objects.get(id=submission_id)
subtag = SubmissionTag.objects.get(id=subtag_id)
subtag = SubmissionTag.objects.get(id=subtag_id, course_instance=self.instance)

# Delete SubmissionTagging object
SubmissionTagging.objects.filter(submission=submission, tag=subtag).delete()

# Redirect back to the previous page
return redirect(request.META.get('HTTP_REFERER', '/'))

def __init__(self, *args, **kwargs):
self.instance = kwargs.pop('instance', None)
super().__init__(*args, **kwargs)



class ExerciseInfoView(ExerciseBaseView):
ajax_template_name = "exercise/_exercise_info.html"


class ExerciseView(BaseRedirectMixin, ExerciseBaseView, EnrollableViewMixin):
template_name = "exercise/exercise.html"
ajax_template_name = "exercise/exercise_plain.html"
Expand Down
5 changes: 0 additions & 5 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,6 @@ msgstr "Tags"
#: edit_course/templates/edit_course/submissiontag_delete.html
#: edit_course/templates/edit_course/submissiontag_edit.html
#: edit_course/templates/edit_course/submissiontag_list.html
#: edit_course/templates/edit_course/submissiontagging_add.html
msgid "SUBMISSION_TAGS"
msgstr "Submission tags"

Expand Down Expand Up @@ -2911,10 +2910,6 @@ msgstr "No student tags."
msgid "ADD_NEW_USER_TAGGING"
msgstr "Add new user tagging"

#: edit_course/templates/edit_course/submissiontagging_add.html
msgid "ADD_NEW_SUBMISSION_TAGGING"
msgstr "Add new submission tagging"

#: exercise/forms.py exercise/templates/exercise/staff/_assessment_panel.html
msgid "ADD_TAGGING"
msgstr "Add tagging"
Expand Down
5 changes: 0 additions & 5 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,6 @@ msgstr "Merkinnät"
#: edit_course/templates/edit_course/submissiontag_delete.html
#: edit_course/templates/edit_course/submissiontag_edit.html
#: edit_course/templates/edit_course/submissiontag_list.html
#: edit_course/templates/edit_course/submissiontagging_add.html
msgid "SUBMISSION_TAGS"
msgstr "Palautusmerkinnät"

Expand Down Expand Up @@ -2926,10 +2925,6 @@ msgstr "Ei opiskelijamerkintöjä."
msgid "ADD_NEW_USER_TAGGING"
msgstr "Merkitse opiskelijoita"

#: edit_course/templates/edit_course/submissiontagging_add.html
msgid "ADD_NEW_SUBMISSION_TAGGING"
msgstr "Merkitse palautuksia"

#: exercise/forms.py exercise/templates/exercise/staff/_assessment_panel.html
msgid "ADD_TAGGING"
msgstr "Lisää merkintä"
Expand Down

0 comments on commit 5777ef5

Please sign in to comment.