.
This commit is contained in:
+14
-1
@@ -23,6 +23,7 @@ from rapids.models import (
|
|||||||
|
|
||||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||||
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class RapidAnswerForm(ModelForm):
|
class RapidAnswerForm(ModelForm):
|
||||||
@@ -189,7 +190,7 @@ class RapidForm(ModelForm):
|
|||||||
ImageFormSet = inlineformset_factory(
|
ImageFormSet = inlineformset_factory(
|
||||||
Rapid,
|
Rapid,
|
||||||
RapidImage,
|
RapidImage,
|
||||||
fields=["image", "feedback_image", "description"],
|
fields=["image", "feedback_image", "filename", "description"],
|
||||||
exclude=[],
|
exclude=[],
|
||||||
can_delete=True,
|
can_delete=True,
|
||||||
extra=1,
|
extra=1,
|
||||||
@@ -244,3 +245,15 @@ class ExamForm(ExamFormMixin, ModelForm):
|
|||||||
"cid_user_groups",
|
"cid_user_groups",
|
||||||
#"author",
|
#"author",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class ExamAuthorForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Exam
|
||||||
|
fields = ["author"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
ModelForm.__init__(self, *args, **kwargs)
|
||||||
|
self.fields["author"] = ModelMultipleChoiceField(
|
||||||
|
queryset=User.objects.all(),
|
||||||
|
widget=FilteredSelectMultiple(verbose_name="Authors", is_stacked=False),
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.13 on 2022-05-18 16:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rapids', '0051_exam_authors_only'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='rapidimage',
|
||||||
|
name='filename',
|
||||||
|
field=models.CharField(blank=True, help_text='Name of the original file when uploaded', max_length=255, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -501,6 +501,8 @@ class RapidImage(models.Model):
|
|||||||
|
|
||||||
feedback_image = models.BooleanField(default=False)
|
feedback_image = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
filename = models.CharField(max_length=255, null=True, blank=True, help_text="Name of the original file when uploaded")
|
||||||
|
|
||||||
description = models.CharField(max_length=255, null=True, blank=True)
|
description = models.CharField(max_length=255, null=True, blank=True)
|
||||||
|
|
||||||
image_md5_hash = models.CharField(max_length=32, null=True, blank=True)
|
image_md5_hash = models.CharField(max_length=32, null=True, blank=True)
|
||||||
|
|||||||
@@ -212,7 +212,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
dropContainer.ondrop = function (evt) {
|
dropContainer.ondrop = function (evt) {
|
||||||
console.log("SHIT", evt);
|
|
||||||
$(evt.target).removeClass("drop-target-active");
|
$(evt.target).removeClass("drop-target-active");
|
||||||
|
|
||||||
file_drop_number = evt.dataTransfer.files.length;
|
file_drop_number = evt.dataTransfer.files.length;
|
||||||
@@ -621,7 +620,8 @@
|
|||||||
// If a (new) file is being uploaded we save it's name prior to it being hashed
|
// If a (new) file is being uploaded we save it's name prior to it being hashed
|
||||||
if (file_element.files.length > 0) {
|
if (file_element.files.length > 0) {
|
||||||
file_name = file_element.files[0].name
|
file_name = file_element.files[0].name
|
||||||
$(ul).find("input[type=text]").val(file_name);
|
//$(ul).find("input[type=text]").val(file_name);
|
||||||
|
$(ul).find("input[name~='filename']").val(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_element.files.length > 0 || $(ul).find(":contains('Currently:')")) {
|
if (file_element.files.length > 0 || $(ul).find(":contains('Currently:')")) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ urlpatterns = [
|
|||||||
name="exam_question_detail",
|
name="exam_question_detail",
|
||||||
),
|
),
|
||||||
path("exam/<int:pk>/", views.GenericExamViews.exam_overview, name="exam_overview"),
|
path("exam/<int:pk>/", views.GenericExamViews.exam_overview, name="exam_overview"),
|
||||||
|
path("exam/<int:pk>/authors", views.ExamAuthorUpdate.as_view(), name="exam_authors"),
|
||||||
path(
|
path(
|
||||||
"exam/<int:pk>/json_edit",
|
"exam/<int:pk>/json_edit",
|
||||||
views.GenericExamViews.exam_json_edit,
|
views.GenericExamViews.exam_json_edit,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ from django.http import Http404, JsonResponse
|
|||||||
from django.http import HttpResponseRedirect, HttpResponse
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
|
ExamAuthorForm,
|
||||||
RapidForm,
|
RapidForm,
|
||||||
MarkRapidQuestionForm,
|
MarkRapidQuestionForm,
|
||||||
ImageFormSet,
|
ImageFormSet,
|
||||||
@@ -858,6 +859,10 @@ class ExamUpdate(
|
|||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
#TODO: AUTHOR REQURIED (NOT AUTHORORCHECKER)
|
||||||
|
class ExamAuthorUpdate(RevisionMixin, LoginRequiredMixin, AuthorOrCheckerRequiredMixin, UpdateView):
|
||||||
|
model = Exam
|
||||||
|
form_class = ExamAuthorForm
|
||||||
|
|
||||||
class ExamDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
class ExamDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
|
||||||
model = Exam
|
model = Exam
|
||||||
|
|||||||
Reference in New Issue
Block a user