.
This commit is contained in:
+9
-14
@@ -3,17 +3,12 @@ import django_filters
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
#class UserAnswerFilter(django_filters.FilterSet):
|
||||
# class Meta:
|
||||
# #model = AnatomyQuestion
|
||||
# abstract = True
|
||||
# fields = (
|
||||
# "cid",
|
||||
# "question",
|
||||
# "answer",
|
||||
# #"answer_compare",
|
||||
# "exam",
|
||||
# "created",
|
||||
# "updateded",
|
||||
# "created_date",
|
||||
# )
|
||||
from generic.models import CidUser
|
||||
|
||||
class CidUserFilter(django_filters.FilterSet):
|
||||
class Meta:
|
||||
model = CidUser
|
||||
fields = (
|
||||
"cid",
|
||||
"active",
|
||||
)
|
||||
@@ -190,6 +190,7 @@ class QuestionNote(models.Model):
|
||||
class CidUser(models.Model):
|
||||
cid = models.IntegerField(blank=True, null=True)
|
||||
passcode = models.CharField(blank=True, max_length=50)
|
||||
active = models.BinaryField(default=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.cid)
|
||||
|
||||
+25
-28
@@ -7,6 +7,8 @@ from easy_thumbnails.files import get_thumbnailer
|
||||
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
from generic.models import CidUser
|
||||
|
||||
|
||||
class ImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
@@ -17,31 +19,26 @@ class ImageColumn(tables.Column):
|
||||
return format_html('<span title="{}">Invalid image url<span>', value)
|
||||
|
||||
|
||||
#class UserAnswerTable(tables.Table):
|
||||
# #edit = tables.LinkColumn(
|
||||
# # "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
# #)
|
||||
# #view = tables.LinkColumn(
|
||||
# # "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||
# #)
|
||||
# #image = ImageColumn("image", orderable=False)
|
||||
# # clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||
# # text='Clone',
|
||||
# # args=[A('pk')],
|
||||
# # orderable=False)
|
||||
# #exams = tables.ManyToManyColumn(verbose_name="Exams")
|
||||
#
|
||||
# class Meta:
|
||||
# #model = AnatomyQuestion
|
||||
# abstract = True
|
||||
# template_name = "django_tables2/bootstrap4.html"
|
||||
# fields = (
|
||||
# "cid",
|
||||
# "question",
|
||||
# "answer",
|
||||
# #"answer_compare",
|
||||
# "exam",
|
||||
# "created",
|
||||
# "updated",
|
||||
# )
|
||||
# #sequence = ("view")
|
||||
class CidUserTable(tables.Table):
|
||||
#edit = tables.LinkColumn(
|
||||
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
#)
|
||||
#view = tables.LinkColumn(
|
||||
# "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||
#)
|
||||
#image = ImageColumn("image", orderable=False)
|
||||
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||
# text='Clone',
|
||||
# args=[A('pk')],
|
||||
# orderable=False)
|
||||
physics_exams = tables.ManyToManyColumn(verbose_name="Physics Exams")
|
||||
|
||||
class Meta:
|
||||
model = CidUser
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
fields = (
|
||||
"cid",
|
||||
"passcode",
|
||||
"active",
|
||||
)
|
||||
#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",
|
||||
),
|
||||
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
|
||||
|
||||
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 (
|
||||
ExaminationForm,
|
||||
)
|
||||
|
||||
from .models import Examination, QuestionNote
|
||||
from .models import CidUser, Examination, QuestionNote
|
||||
|
||||
from rapids.models import Rapid as RapidQuestion
|
||||
from rapids.models import Exam as RapidExam
|
||||
@@ -830,4 +835,12 @@ class ExaminationAutocomplete(autocomplete.Select2QuerySetView):
|
||||
except FieldError:
|
||||
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