.
This commit is contained in:
+22
-14
@@ -9,9 +9,7 @@ from django.forms import (
|
|||||||
)
|
)
|
||||||
from django.forms import inlineformset_factory
|
from django.forms import inlineformset_factory
|
||||||
|
|
||||||
from generic.models import (
|
from generic.models import CidUser, Examination, QuestionNote
|
||||||
CidUser, Examination, QuestionNote
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
||||||
@@ -24,50 +22,60 @@ from django.shortcuts import render, get_object_or_404, redirect
|
|||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
|
|
||||||
class ExaminationForm(ModelForm):
|
class ExaminationForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Examination
|
model = Examination
|
||||||
fields = ["examination"]
|
fields = ["examination"]
|
||||||
|
|
||||||
|
|
||||||
class QuestionNoteForm(ModelForm):
|
class QuestionNoteForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QuestionNote
|
model = QuestionNote
|
||||||
fields = ["content_type", "object_id", "author", "note_type", "note"]
|
fields = ["content_type", "object_id", "author", "note_type", "note"]
|
||||||
widgets = {'content_type': HiddenInput(), 'object_id': HiddenInput()}
|
widgets = {"content_type": HiddenInput(), "object_id": HiddenInput()}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
question_type = kwargs.pop("question_type")
|
question_type = kwargs.pop("question_type")
|
||||||
pk = kwargs.pop("pk")
|
pk = kwargs.pop("pk")
|
||||||
user = kwargs.pop("user")
|
user = kwargs.pop("user")
|
||||||
|
|
||||||
#if question_type == "rapid":
|
# if question_type == "rapid":
|
||||||
# question = Rapid
|
# question = Rapid
|
||||||
# content_type = ContentType.objects.get(model="rapid")
|
# content_type = ContentType.objects.get(model="rapid")
|
||||||
#elif question_type == "anatomy":
|
# elif question_type == "anatomy":
|
||||||
# question = AnatomyQuestion
|
# question = AnatomyQuestion
|
||||||
# content_type = ContentType.objects.get(model="anatomyquestion")
|
# content_type = ContentType.objects.get(model="anatomyquestion")
|
||||||
#elif question_type == "long":
|
# elif question_type == "long":
|
||||||
# question = Long
|
# question = Long
|
||||||
# content_type = ContentType.objects.get(model="long")
|
# content_type = ContentType.objects.get(model="long")
|
||||||
#else:
|
# else:
|
||||||
# raise PermissionError()
|
# raise PermissionError()
|
||||||
|
|
||||||
#get_object_or_404(question, pk=pk)
|
# get_object_or_404(question, pk=pk)
|
||||||
# We get the 'initial' keyword argument or initialize it
|
# We get the 'initial' keyword argument or initialize it
|
||||||
# as a dict if it didn't exist.
|
# as a dict if it didn't exist.
|
||||||
#if kwargs.get("instance"):
|
# if kwargs.get("instance"):
|
||||||
ModelForm.__init__(self, *args, **kwargs)
|
ModelForm.__init__(self, *args, **kwargs)
|
||||||
super(QuestionNoteForm, self).__init__(*args, **kwargs)
|
super(QuestionNoteForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
#initial = kwargs.setdefault("initial", {})
|
# initial = kwargs.setdefault("initial", {})
|
||||||
## The widget for a ModelMultipleChoiceField expects
|
## The widget for a ModelMultipleChoiceField expects
|
||||||
## a list of primary key for the selected data.
|
## a list of primary key for the selected data.
|
||||||
##initial["content_type"] = question
|
##initial["content_type"] = question
|
||||||
##initial["content_id"] = pk
|
##initial["content_id"] = pk
|
||||||
#self.fields["content_type"].initial = content_type
|
# self.fields["content_type"].initial = content_type
|
||||||
#self.fields["object_id"].initial = pk
|
# self.fields["object_id"].initial = pk
|
||||||
|
|
||||||
|
|
||||||
class CidUserForm(ModelForm):
|
class CidUserForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CidUser
|
model = CidUser
|
||||||
fields = ["cid", "passcode", "active", "internal_candidate", "name", "email", "supervisor_email"]
|
fields = [
|
||||||
|
"passcode",
|
||||||
|
"active",
|
||||||
|
"internal_candidate",
|
||||||
|
"name",
|
||||||
|
"email",
|
||||||
|
"supervisor_email",
|
||||||
|
]
|
||||||
|
|||||||
@@ -247,6 +247,9 @@ class CidUser(models.Model):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return str(self.cid)
|
return str(self.cid)
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('generic:manage_cids')
|
||||||
|
|
||||||
def check_passcode(self, passcode) -> bool:
|
def check_passcode(self, passcode) -> bool:
|
||||||
return self.passcode == passcode
|
return self.passcode == passcode
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "atlas/base.html" %}
|
{% extends "generic/base.html" %}
|
||||||
<!-- {% load static from static %} -->
|
<!-- {% load static from static %} -->
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
<!-- {{ form.media }} -->
|
<!-- {{ form.media }} -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Edit CID User</h2>
|
<h2>Edit CID User / {{ciduser.cid}}</h2>
|
||||||
Use this form to create or edit a CID user.
|
Use this form to edit a CID user.
|
||||||
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
|
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user