diff options
author | adityacp | 2020-02-10 17:04:35 +0530 |
---|---|---|
committer | adityacp | 2020-02-10 17:04:35 +0530 |
commit | f9eb4681807c56b9dd67ed370e032e77f9219bf2 (patch) | |
tree | 74ba9afcf2b325d8fef5ba695d6282d0be543d02 | |
parent | 7edfc63ab89d65337e17e8a79e8114a74b2146e3 (diff) | |
download | online_test-f9eb4681807c56b9dd67ed370e032e77f9219bf2.tar.gz online_test-f9eb4681807c56b9dd67ed370e032e77f9219bf2.tar.bz2 online_test-f9eb4681807c56b9dd67ed370e032e77f9219bf2.zip |
Change models.py and admin.py
- Register course status model in admin
- Add object str name in CourseStatus model
- Add filter in the admin for filtering courses
-rw-r--r-- | yaksh/admin.py | 14 | ||||
-rw-r--r-- | yaksh/models.py | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/yaksh/admin.py b/yaksh/admin.py index 7ea8ed6..8944722 100644 --- a/yaksh/admin.py +++ b/yaksh/admin.py @@ -1,6 +1,6 @@ from yaksh.models import Question, Quiz, QuestionPaper, Profile from yaksh.models import (TestCase, StandardTestCase, StdIOBasedTestCase, - Course, AnswerPaper) + Course, AnswerPaper, CourseStatus) from django.contrib import admin @@ -14,12 +14,22 @@ 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'] + + 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(Course, CourseAdmin) admin.site.register(Quiz) admin.site.register(QuestionPaper) admin.site.register(AnswerPaper, AnswerPaperAdmin) +admin.site.register(CourseStatus, CourseStatusAdmin)
\ No newline at end of file diff --git a/yaksh/models.py b/yaksh/models.py index 6edb9ea..d453f81 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1161,6 +1161,9 @@ 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): |