From f9eb4681807c56b9dd67ed370e032e77f9219bf2 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 10 Feb 2020 17:04:35 +0530 Subject: 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 --- yaksh/admin.py | 14 ++++++++++++-- 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): -- cgit From 6c7325350471bcf7437fcc7f08debe19bd0365eb Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 10 Feb 2020 17:10:22 +0530 Subject: Fix pep8 issues --- yaksh/admin.py | 4 ++-- yaksh/models.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/yaksh/admin.py b/yaksh/admin.py index 8944722..efbeb7f 100644 --- a/yaksh/admin.py +++ b/yaksh/admin.py @@ -20,7 +20,7 @@ class CourseStatusAdmin(admin.ModelAdmin): class CourseAdmin(admin.ModelAdmin): - list_filter = ['active', 'is_trial'] + list_filter = ['active', 'is_trial'] admin.site.register(Profile, ProfileAdmin) @@ -32,4 +32,4 @@ 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 +admin.site.register(CourseStatus, CourseStatusAdmin) diff --git a/yaksh/models.py b/yaksh/models.py index d453f81..df37b26 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1162,7 +1162,9 @@ class CourseStatus(models.Model): self.save() def __str__(self): - return "{0} status for {1}".format(self.course.name, self.user.username) + return "{0} status for {1}".format( + self.course.name, self.user.username + ) ############################################################################### -- cgit From 36f890621989e77663b52a46cdef45086fb9fa1d Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 11 Feb 2020 10:22:25 +0530 Subject: Register lesson and learning module in admin --- yaksh/admin.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/yaksh/admin.py b/yaksh/admin.py index efbeb7f..3d09f69 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, CourseStatus) + Course, AnswerPaper, CourseStatus, LearningModule, + Lesson + ) from django.contrib import admin @@ -23,13 +25,27 @@ 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, CourseAdmin) -admin.site.register(Quiz) +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) -- cgit From f20a8da0c4c29398297d02fbeb2f9868cddae7a3 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 12 Feb 2020 16:14:23 +0530 Subject: Fix indentation --- yaksh/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yaksh/admin.py b/yaksh/admin.py index 3d09f69..495b48d 100644 --- a/yaksh/admin.py +++ b/yaksh/admin.py @@ -34,7 +34,7 @@ class LessonAdmin(admin.ModelAdmin): class QuizAdmin(admin.ModelAdmin): - list_filter = ['active', 'is_trial'] + list_filter = ['active', 'is_trial'] admin.site.register(Profile, ProfileAdmin) -- cgit