.
This commit is contained in:
+9
-14
@@ -3,17 +3,12 @@ import django_filters
|
|||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
#class UserAnswerFilter(django_filters.FilterSet):
|
from generic.models import CidUser
|
||||||
# class Meta:
|
|
||||||
# #model = AnatomyQuestion
|
class CidUserFilter(django_filters.FilterSet):
|
||||||
# abstract = True
|
class Meta:
|
||||||
# fields = (
|
model = CidUser
|
||||||
# "cid",
|
fields = (
|
||||||
# "question",
|
"cid",
|
||||||
# "answer",
|
"active",
|
||||||
# #"answer_compare",
|
)
|
||||||
# "exam",
|
|
||||||
# "created",
|
|
||||||
# "updateded",
|
|
||||||
# "created_date",
|
|
||||||
# )
|
|
||||||
@@ -190,6 +190,7 @@ class QuestionNote(models.Model):
|
|||||||
class CidUser(models.Model):
|
class CidUser(models.Model):
|
||||||
cid = models.IntegerField(blank=True, null=True)
|
cid = models.IntegerField(blank=True, null=True)
|
||||||
passcode = models.CharField(blank=True, max_length=50)
|
passcode = models.CharField(blank=True, max_length=50)
|
||||||
|
active = models.BinaryField(default=True)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return str(self.cid)
|
return str(self.cid)
|
||||||
|
|||||||
+25
-28
@@ -7,6 +7,8 @@ from easy_thumbnails.files import get_thumbnailer
|
|||||||
|
|
||||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||||
|
|
||||||
|
from generic.models import CidUser
|
||||||
|
|
||||||
|
|
||||||
class ImageColumn(tables.Column):
|
class ImageColumn(tables.Column):
|
||||||
def render(self, value):
|
def render(self, value):
|
||||||
@@ -17,31 +19,26 @@ class ImageColumn(tables.Column):
|
|||||||
return format_html('<span title="{}">Invalid image url<span>', value)
|
return format_html('<span title="{}">Invalid image url<span>', value)
|
||||||
|
|
||||||
|
|
||||||
#class UserAnswerTable(tables.Table):
|
class CidUserTable(tables.Table):
|
||||||
# #edit = tables.LinkColumn(
|
#edit = tables.LinkColumn(
|
||||||
# # "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||||
# #)
|
#)
|
||||||
# #view = tables.LinkColumn(
|
#view = tables.LinkColumn(
|
||||||
# # "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
# "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||||
# #)
|
#)
|
||||||
# #image = ImageColumn("image", orderable=False)
|
#image = ImageColumn("image", orderable=False)
|
||||||
# # clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||||
# # text='Clone',
|
# text='Clone',
|
||||||
# # args=[A('pk')],
|
# args=[A('pk')],
|
||||||
# # orderable=False)
|
# orderable=False)
|
||||||
# #exams = tables.ManyToManyColumn(verbose_name="Exams")
|
physics_exams = tables.ManyToManyColumn(verbose_name="Physics Exams")
|
||||||
#
|
|
||||||
# class Meta:
|
class Meta:
|
||||||
# #model = AnatomyQuestion
|
model = CidUser
|
||||||
# abstract = True
|
template_name = "django_tables2/bootstrap4.html"
|
||||||
# template_name = "django_tables2/bootstrap4.html"
|
fields = (
|
||||||
# fields = (
|
"cid",
|
||||||
# "cid",
|
"passcode",
|
||||||
# "question",
|
"active",
|
||||||
# "answer",
|
)
|
||||||
# #"answer_compare",
|
#sequence = ("view")
|
||||||
# "exam",
|
|
||||||
# "created",
|
|
||||||
# "updated",
|
|
||||||
# )
|
|
||||||
# #sequence = ("view")
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
{% block css %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div id="view-filter-options">
|
||||||
|
<h3>Filter CID Users </h3>
|
||||||
|
<form action="" method="get">
|
||||||
|
{{ filter.form }}
|
||||||
|
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% render_table table %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{% endblock %}
|
||||||
+1
-1
@@ -26,5 +26,5 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
name="examination-autocomplete",
|
name="examination-autocomplete",
|
||||||
),
|
),
|
||||||
path("cids/manage/", views.create_examination, name="create_examination"),
|
path("cids/manage/", views.CidUserView.as_view(), name="manage_cids"),
|
||||||
]
|
]
|
||||||
|
|||||||
+15
-2
@@ -23,12 +23,17 @@ import json
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
from django_filters.views import FilterView
|
||||||
|
from django_tables2.views import SingleTableMixin
|
||||||
|
from generic.filters import CidUserFilter
|
||||||
|
|
||||||
|
from generic.tables import CidUserTable
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .models import Examination, QuestionNote
|
from .models import CidUser, Examination, QuestionNote
|
||||||
|
|
||||||
from rapids.models import Rapid as RapidQuestion
|
from rapids.models import Rapid as RapidQuestion
|
||||||
from rapids.models import Exam as RapidExam
|
from rapids.models import Exam as RapidExam
|
||||||
@@ -830,4 +835,12 @@ class ExaminationAutocomplete(autocomplete.Select2QuerySetView):
|
|||||||
except FieldError:
|
except FieldError:
|
||||||
return Examination.objects.none()
|
return Examination.objects.none()
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||||
|
model = CidUser
|
||||||
|
table_class = CidUserTable
|
||||||
|
template_name = "generic/question_view.html"
|
||||||
|
|
||||||
|
filterset_class = CidUserFilter
|
||||||
Reference in New Issue
Block a user