summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2020-02-13 08:54:47 +0530
committerGitHub2020-02-13 08:54:47 +0530
commit32f1d4dc7816bbb93f6dda77591eeb75c3f30c0d (patch)
tree4abce8ff313a06796f6654d2a69738bebce86ecf
parent4aaadc163debb33f20b9445edfd20d1cbec5cdd2 (diff)
parentf20a8da0c4c29398297d02fbeb2f9868cddae7a3 (diff)
downloadonline_test-32f1d4dc7816bbb93f6dda77591eeb75c3f30c0d.tar.gz
online_test-32f1d4dc7816bbb93f6dda77591eeb75c3f30c0d.tar.bz2
online_test-32f1d4dc7816bbb93f6dda77591eeb75c3f30c0d.zip
Merge pull request #647 from adityacp/register_admin_models
Register models in admin and add filters
-rw-r--r--yaksh/admin.py32
-rw-r--r--yaksh/models.py5
2 files changed, 34 insertions, 3 deletions
diff --git a/yaksh/admin.py b/yaksh/admin.py
index 7ea8ed6..495b48d 100644
--- a/yaksh/admin.py
+++ b/yaksh/admin.py
@@ -1,6 +1,8 @@
from yaksh.models import Question, Quiz, QuestionPaper, Profile
from yaksh.models import (TestCase, StandardTestCase, StdIOBasedTestCase,
- Course, AnswerPaper)
+ Course, AnswerPaper, CourseStatus, LearningModule,
+ Lesson
+ )
from django.contrib import admin
@@ -14,12 +16,36 @@ class ProfileAdmin(admin.ModelAdmin):
"roll_number", "institute", "department"]
+class CourseStatusAdmin(admin.ModelAdmin):
+ search_fields = ['user__first_name', 'user__last_name', 'user__username']
+ list_filter = ['course__is_trial']
+
+
+class CourseAdmin(admin.ModelAdmin):
+ list_filter = ['active', 'is_trial']
+
+
+class LearningModuleAdmin(admin.ModelAdmin):
+ list_filter = ['active', 'is_trial']
+
+
+class LessonAdmin(admin.ModelAdmin):
+ list_filter = ['active']
+
+
+class QuizAdmin(admin.ModelAdmin):
+ list_filter = ['active', 'is_trial']
+
+
admin.site.register(Profile, ProfileAdmin)
admin.site.register(Question)
admin.site.register(TestCase)
admin.site.register(StandardTestCase)
admin.site.register(StdIOBasedTestCase)
-admin.site.register(Course)
-admin.site.register(Quiz)
+admin.site.register(Course, CourseAdmin)
+admin.site.register(Quiz, QuizAdmin)
admin.site.register(QuestionPaper)
admin.site.register(AnswerPaper, AnswerPaperAdmin)
+admin.site.register(CourseStatus, CourseStatusAdmin)
+admin.site.register(Lesson, LessonAdmin)
+admin.site.register(LearningModule, LearningModuleAdmin)
diff --git a/yaksh/models.py b/yaksh/models.py
index 6edb9ea..df37b26 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1161,6 +1161,11 @@ class CourseStatus(models.Model):
self.current_unit = unit
self.save()
+ def __str__(self):
+ return "{0} status for {1}".format(
+ self.course.name, self.user.username
+ )
+
###############################################################################
class ConcurrentUser(models.Model):