From 7184865feddeb49d0d277a4767ad7e3933d12efd Mon Sep 17 00:00:00 2001 From: "329576@uwr.edu.pl" <329576@uwr.edu.pl> Date: Sun, 5 Jan 2025 15:15:05 +0100 Subject: [PATCH] Remove effects --- zapisy/apps/effects/models.py | 13 -------- zapisy/apps/effects/templates/effects.html | 8 ----- zapisy/apps/enrollment/courses/admin.py | 24 +------------- .../migrations/0037_auto_20250105_1457.py | 20 ++++++++++++ .../courses/models/course_information.py | 5 --- .../courses/models/course_instance.py | 1 - .../apps/enrollment/courses/models/effects.py | 21 ------------- .../courses/course_parts/course_head.html | 10 ------ zapisy/apps/enrollment/courses/views.py | 6 ++-- .../assets/components/CourseFilter.vue | 31 ++++++------------- .../enrollment/timetable/assets/models.ts | 1 - .../timetable/assets/store/courses.ts | 1 - zapisy/apps/enrollment/timetable/views.py | 2 +- zapisy/apps/offer/proposal/admin.py | 2 +- .../assets/components/CourseFilter.vue | 31 ++++++------------- .../templates/proposal/proposal_info.html | 10 ------ zapisy/apps/offer/proposal/views.py | 2 +- .../vote/assets/components/CourseFilter.vue | 31 ++++++------------- zapisy/apps/offer/vote/views.py | 2 +- .../users/templates/users/my_profile.html | 3 -- zapisy/apps/users/tests/test_admin.py | 1 - zapisy/apps/users/views.py | 4 --- 22 files changed, 58 insertions(+), 171 deletions(-) delete mode 100644 zapisy/apps/effects/templates/effects.html create mode 100644 zapisy/apps/enrollment/courses/migrations/0037_auto_20250105_1457.py delete mode 100644 zapisy/apps/enrollment/courses/models/effects.py diff --git a/zapisy/apps/effects/models.py b/zapisy/apps/effects/models.py index f3e61fd60c..b662fa7b47 100644 --- a/zapisy/apps/effects/models.py +++ b/zapisy/apps/effects/models.py @@ -14,16 +14,3 @@ class CompletedCourses(models.Model): class Meta: unique_together = ('student', 'course', 'program') - - def get_completed_effects(student: Student) -> Set[str]: - completed_courses = ( - CompletedCourses.objects.filter(student=student, program=student.program) - .select_related('course').prefetch_related('course__effects') - ) - - done_effects = set() - for record in completed_courses: - for effect in record.course.effects.all(): - done_effects.add(effect.group_name) - - return done_effects diff --git a/zapisy/apps/effects/templates/effects.html b/zapisy/apps/effects/templates/effects.html deleted file mode 100644 index 54aea3e3ba..0000000000 --- a/zapisy/apps/effects/templates/effects.html +++ /dev/null @@ -1,8 +0,0 @@ - - Zrealizowane grupy efektów kształcenia - - {% for effect in effects %} - {{ effect }} - {% endfor %} - - diff --git a/zapisy/apps/enrollment/courses/admin.py b/zapisy/apps/enrollment/courses/admin.py index 95181dd4b8..eaf5bfe639 100644 --- a/zapisy/apps/enrollment/courses/admin.py +++ b/zapisy/apps/enrollment/courses/admin.py @@ -4,7 +4,6 @@ from apps.enrollment.courses.models.classroom import Classroom from apps.enrollment.courses.models.course_instance import CourseInstance from apps.enrollment.courses.models.course_type import Type -from apps.enrollment.courses.models.effects import Effects from apps.enrollment.courses.models.group import Group, GuaranteedSpots from apps.enrollment.courses.models.semester import ChangedDay, Freeday, Semester from apps.enrollment.courses.models.tag import Tag @@ -74,26 +73,6 @@ class FreedayAdmin(admin.ModelAdmin): ordering = ('-day',) -class EffectsListFilter(SimpleListFilter): - title = 'Grupa efektów kształcenia' - - # Parameter for the filter that will be used in the URL query. - parameter_name = 'effects' - - def lookups(self, request, model_admin): - result = [] - for effect in Effects.objects.all(): - result.append((str(effect.id), effect)) - - return result - - def queryset(self, request, queryset): - if self.value(): - return queryset.filter(effects=self.value()) - else: - return queryset - - class TermInline(admin.TabularInline): model = Term extra = 0 @@ -175,7 +154,7 @@ def get_queryset(self, request): @admin.register(CourseInstance) class CourseInstanceAdmin(admin.ModelAdmin): list_filter = ('semester', 'course_type', ('owner', admin.RelatedOnlyFieldListFilter), - 'tags', 'effects',) + 'tags') list_display = ('name', 'owner', 'course_type', 'semester',) search_fields = ('name', 'name_en') ordering = ('semester', 'owner', 'offer') @@ -194,7 +173,6 @@ class TypeAdmin(admin.ModelAdmin): admin.site.register(Group, GroupAdmin) admin.site.register(Tag) -admin.site.register(Effects) admin.site.register(Classroom, ClassroomAdmin) admin.site.register(Semester, SemesterAdmin) admin.site.register(Freeday, FreedayAdmin) diff --git a/zapisy/apps/enrollment/courses/migrations/0037_auto_20250105_1457.py b/zapisy/apps/enrollment/courses/migrations/0037_auto_20250105_1457.py new file mode 100644 index 0000000000..fea2653a04 --- /dev/null +++ b/zapisy/apps/enrollment/courses/migrations/0037_auto_20250105_1457.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.14 on 2025-01-05 14:57 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('courses', '0036_auto_20211022_1641'), + ] + + operations = [ + migrations.RemoveField( + model_name='courseinformation', + name='effects', + ), + migrations.DeleteModel( + name='Effects', + ), + ] diff --git a/zapisy/apps/enrollment/courses/models/course_information.py b/zapisy/apps/enrollment/courses/models/course_information.py index d082a0ba60..5b728bb4fd 100644 --- a/zapisy/apps/enrollment/courses/models/course_information.py +++ b/zapisy/apps/enrollment/courses/models/course_information.py @@ -13,7 +13,6 @@ from apps.users.models import Employee from .course_type import Type as CourseType -from .effects import Effects from .tag import Tag @@ -73,7 +72,6 @@ class CourseInformation(models.Model): discipline = models.CharField("dyscyplina", max_length=100, default="Informatyka") tags = models.ManyToManyField(Tag, verbose_name="tagi", blank=True) - effects = models.ManyToManyField(Effects, verbose_name="grupy efektów kształcenia", blank=True) created = models.DateTimeField("Data utworzenia", auto_now_add=True) modified = models.DateTimeField("Data modyfikacji", auto_now=True) @@ -120,7 +118,6 @@ def __json__(self): 'courseType': self.course_type_id, 'recommendedForFirstYear': self.recommended_for_first_year, 'owner': self.owner_id, - 'effects': [effect.pk for effect in self.effects.all()], 'tags': [tag.pk for tag in self.tags.all()], } @@ -130,13 +127,11 @@ def get_short_name(self): @staticmethod def prepare_filter_data(qs: models.QuerySet) -> Dict: """Prepares the data for course filter based on a given queryset.""" - all_effects = Effects.objects.all().values_list('id', 'group_name', named=True) all_tags = Tag.objects.all().values_list('id', 'full_name', named=True) all_owners = qs.values_list( 'owner', 'owner__user__first_name', 'owner__user__last_name', named=True).distinct() all_types = qs.values_list('course_type', 'course_type__name', named=True).distinct() return { - 'allEffects': {e.id: e.group_name for e in all_effects}, 'allTags': {t.id: t.full_name for t in all_tags}, 'allOwners': { o.owner: [o.owner__user__first_name, o.owner__user__last_name] for o in all_owners diff --git a/zapisy/apps/enrollment/courses/models/course_instance.py b/zapisy/apps/enrollment/courses/models/course_instance.py index b827f3e6e5..c69c714ce7 100644 --- a/zapisy/apps/enrollment/courses/models/course_instance.py +++ b/zapisy/apps/enrollment/courses/models/course_instance.py @@ -57,7 +57,6 @@ def create_proposal_instance(cls, proposal: Proposal, semester: Semester): instance = cls(**proposal_dict) instance.save() instance.tags.set(proposal.tags.all()) - instance.effects.set(proposal.effects.all()) return instance @classmethod diff --git a/zapisy/apps/enrollment/courses/models/effects.py b/zapisy/apps/enrollment/courses/models/effects.py deleted file mode 100644 index a8df76bdc6..0000000000 --- a/zapisy/apps/enrollment/courses/models/effects.py +++ /dev/null @@ -1,21 +0,0 @@ -from django.db import models - - -class Effects(models.Model): - group_name = models.CharField(max_length=250, verbose_name='grupa efektów') - description = models.TextField(verbose_name='opis', null=True, blank=True) - - class Meta: - verbose_name = 'Grupa Efektów' - verbose_name_plural = 'Grupy Efektów' - app_label = 'courses' - - def __str__(self): - return self.group_name - - def serialize_for_json(self): - return { - 'id': self.pk, - 'name': self.group_name, - 'description': self.description - } diff --git a/zapisy/apps/enrollment/courses/templates/courses/course_parts/course_head.html b/zapisy/apps/enrollment/courses/templates/courses/course_parts/course_head.html index 39896e2ff9..fccc1aa78d 100644 --- a/zapisy/apps/enrollment/courses/templates/courses/course_parts/course_head.html +++ b/zapisy/apps/enrollment/courses/templates/courses/course_parts/course_head.html @@ -76,16 +76,6 @@

{% endif %} - {% if course.effects.all %} - - Grupy efektów kształcenia - - {% for effect in course.effects.all %} - {{ effect }} - {% endfor %} - - - {% endif %} diff --git a/zapisy/apps/enrollment/courses/views.py b/zapisy/apps/enrollment/courses/views.py index bcbb0bb6cd..f1df9fe635 100644 --- a/zapisy/apps/enrollment/courses/views.py +++ b/zapisy/apps/enrollment/courses/views.py @@ -32,7 +32,7 @@ def prepare_courses_list_data(semester: Optional[Semester]): """Returns a dict used by course list and filter in various views.""" qs = CourseInstance.objects.filter(semester=semester).order_by('name') courses = [] - for course in qs.prefetch_related('effects', 'tags'): + for course in qs.prefetch_related('tags'): course_dict = course.__json__() course_dict.update({ 'url': reverse('course-page', args=(course.slug,)), @@ -68,7 +68,7 @@ def course_view_data(request, slug) -> Tuple[Optional[CourseInstance], Optional[ course: CourseInstance try: course = CourseInstance.objects.filter(slug=slug).select_related( - 'semester', 'course_type').prefetch_related('tags', 'effects').get() + 'semester', 'course_type').prefetch_related('tags').get() except CourseInstance.DoesNotExist: return None, None @@ -332,7 +332,7 @@ def get_all_group_ids_for_course_slug(slug, class_type: int = None): course = ( CourseInstance.objects.filter(slug=slug) .select_related('semester', 'course_type') - .prefetch_related('tags', 'effects') + .prefetch_related('tags') .get() ) except CourseInstance.DoesNotExist: diff --git a/zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue b/zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue index b7fbafc6f1..5bbac13ca5 100644 --- a/zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue +++ b/zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue @@ -19,7 +19,6 @@ export default Vue.extend({ }, data: function () { return { - allEffects: {}, allTags: {}, allOwners: [] as MultiselectFilterData, allTypes: [] as MultiselectFilterData, @@ -31,7 +30,6 @@ export default Vue.extend({ const filtersData = JSON.parse( document.getElementById("filters-data")!.innerHTML ) as FilterDataJSON; - this.allEffects = cloneDeep(filtersData.allEffects); this.allTags = cloneDeep(filtersData.allTags); this.allOwners = toPairs(filtersData.allOwners) .sort(([id, [firstname, lastname]], [id2, [firstname2, lastname2]]) => { @@ -89,25 +87,16 @@ export default Vue.extend({ />
- -
- -
-
+
+ +
; tags: Array; owner: number; recommendedForFirstYear: boolean; diff --git a/zapisy/apps/enrollment/timetable/views.py b/zapisy/apps/enrollment/timetable/views.py index 60c44bb36d..937a1b67fb 100644 --- a/zapisy/apps/enrollment/timetable/views.py +++ b/zapisy/apps/enrollment/timetable/views.py @@ -73,7 +73,7 @@ def list_courses_in_semester(semester: Semester): This list will be used in prototype. """ - qs = CourseInstance.objects.filter(semester=semester).prefetch_related('effects', 'tags') + qs = CourseInstance.objects.filter(semester=semester).prefetch_related('tags') courses = [] for course in qs: course_dict = course.__json__() diff --git a/zapisy/apps/offer/proposal/admin.py b/zapisy/apps/offer/proposal/admin.py index 9bc412ba1b..27004aa0df 100644 --- a/zapisy/apps/offer/proposal/admin.py +++ b/zapisy/apps/offer/proposal/admin.py @@ -11,7 +11,7 @@ @admin.register(Proposal) class ProposalAdmin(admin.ModelAdmin): list_filter = ('status', 'semester', 'course_type', ('owner', admin.RelatedOnlyFieldListFilter), - 'modified', 'tags', 'effects', ('courseinstance__semester', + 'modified', 'tags', ('courseinstance__semester', admin.RelatedOnlyFieldListFilter)) list_display = ('name', 'owner', 'course_type', 'semester', 'status', 'modified', 'last_semester') diff --git a/zapisy/apps/offer/proposal/assets/components/CourseFilter.vue b/zapisy/apps/offer/proposal/assets/components/CourseFilter.vue index d719d1e4a6..e9a715e4f4 100644 --- a/zapisy/apps/offer/proposal/assets/components/CourseFilter.vue +++ b/zapisy/apps/offer/proposal/assets/components/CourseFilter.vue @@ -22,7 +22,6 @@ export default Vue.extend({ }, data: function () { return { - allEffects: {}, allTags: {}, allOwners: [] as MultiselectFilterData, allSemesters: [] as MultiselectFilterData, @@ -36,7 +35,6 @@ export default Vue.extend({ const filtersData = JSON.parse( document.getElementById("filters-data")!.innerHTML ) as FilterDataJSON; - this.allEffects = cloneDeep(filtersData.allEffects); this.allTags = cloneDeep(filtersData.allTags); this.allOwners = toPairs(filtersData.allOwners) .sort(([id, [firstname, lastname]], [id2, [firstname2, lastname2]]) => { @@ -104,25 +102,16 @@ export default Vue.extend({ />
- -
- -
-
+
+ +
{% endif %} - {% if course.effects.all %} - - Grupy efektów kształcenia - - {% for effect in course.effects.all %} - {{ effect }} - {% endfor %} - - - {% endif %} diff --git a/zapisy/apps/offer/proposal/views.py b/zapisy/apps/offer/proposal/views.py index a8510bdc70..b7788cf740 100644 --- a/zapisy/apps/offer/proposal/views.py +++ b/zapisy/apps/offer/proposal/views.py @@ -27,7 +27,7 @@ def offer(request, slug=None): filter_statuses = [ProposalStatus.IN_OFFER, ProposalStatus.IN_VOTE, ProposalStatus.WITHDRAWN] qs = Proposal.objects.filter(status__in=filter_statuses).order_by('name') proposal_list = [] - for p in qs.prefetch_related('effects', 'tags'): + for p in qs.prefetch_related('tags'): proposal_dict = p.__json__() proposal_dict.update({ 'status': ProposalStatus(p.status)._name_, diff --git a/zapisy/apps/offer/vote/assets/components/CourseFilter.vue b/zapisy/apps/offer/vote/assets/components/CourseFilter.vue index af456e672d..887677cdf1 100644 --- a/zapisy/apps/offer/vote/assets/components/CourseFilter.vue +++ b/zapisy/apps/offer/vote/assets/components/CourseFilter.vue @@ -23,7 +23,6 @@ export default Vue.extend({ props: { refreshFun: Function }, data: function () { return { - allEffects: {}, allTags: {}, allOwners: [] as MultiselectFilterData, allSemesters: [] as MultiselectFilterData, @@ -36,7 +35,6 @@ export default Vue.extend({ const filtersData = JSON.parse( document.getElementById("filters-data")!.innerHTML ) as FilterDataJSON; - this.allEffects = cloneDeep(filtersData.allEffects); this.allTags = cloneDeep(filtersData.allTags); this.allOwners = toPairs(filtersData.allOwners) .sort(([id, [firstname, lastname]], [id2, [firstname2, lastname2]]) => { @@ -109,25 +107,16 @@ export default Vue.extend({ />
- -
- -
-
+
+ +
Moje studia

Aktualny semestr {{ semester }} - {% if effects %} - {% include "effects.html" with effects=effects only %} - {% endif %} {% endif %} diff --git a/zapisy/apps/users/tests/test_admin.py b/zapisy/apps/users/tests/test_admin.py index 3ec584ee92..16c3d7ed4f 100644 --- a/zapisy/apps/users/tests/test_admin.py +++ b/zapisy/apps/users/tests/test_admin.py @@ -12,7 +12,6 @@ class AdminTestCase(TestCase): "/fereol_admin/courses/freeday/", "/fereol_admin/courses/changedday/", "/fereol_admin/courses/group/", - "/fereol_admin/courses/effects/", "/fereol_admin/courses/courseinstance/", "/fereol_admin/courses/type/", "/fereol_admin/courses/classroom/", diff --git a/zapisy/apps/users/views.py b/zapisy/apps/users/views.py index a7f5753148..3b6cad5ae8 100644 --- a/zapisy/apps/users/views.py +++ b/zapisy/apps/users/views.py @@ -174,10 +174,6 @@ def my_profile(request): if semester and request.user.student: student: Student = request.user.student - done_effects = CompletedCourses.get_completed_effects(student) - data.update({ - 'effects': done_effects, - }) groups_opening_times = GroupOpeningTimes.objects.filter( student_id=student.pk, group__course__semester_id=semester.pk).select_related( 'group', 'group__course', 'group__teacher',