Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1743 Usunięcie efektów kształcenia #1780

Open
wants to merge 3 commits into
base: master-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions zapisy/apps/effects/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Set

from django.db import models

from apps.enrollment.courses.models.course_instance import CourseInstance
Expand All @@ -14,16 +12,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
8 changes: 0 additions & 8 deletions zapisy/apps/effects/templates/effects.html

This file was deleted.

25 changes: 1 addition & 24 deletions zapisy/apps/enrollment/courses/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.contrib import admin, messages
from django.contrib.admin import SimpleListFilter

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
Expand Down Expand Up @@ -74,26 +72,6 @@ class FreedayAdmin(admin.ModelAdmin):
ordering = ('-day',)


class EffectsListFilter(SimpleListFilter):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To chyba już teraz był martwy kod, prawda? Proszę przy okazji o przejechanie się po historii git bisect i stwierdzenie, od kiedy tak jest, tj. kiedy znikają odniesienia do tej klasy.

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
Expand Down Expand Up @@ -175,7 +153,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')
Expand All @@ -194,7 +172,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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
),
]
5 changes: 0 additions & 5 deletions zapisy/apps/enrollment/courses/models/course_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()],
}

Expand 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
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/courses/models/course_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions zapisy/apps/enrollment/courses/models/effects.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ <h1 class="d-inline-block">
</td>
</tr>
{% endif %}
{% if course.effects.all %}
<tr>
<th>Grupy efektów kształcenia</th>
<td>
{% for effect in course.effects.all %}
<span class="badge bg-info me-2">{{ effect }}</span>
{% endfor %}
</td>
</tr>
{% endif %}
</tbody>
</table>

Expand Down
6 changes: 3 additions & 3 deletions zapisy/apps/enrollment/courses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)),
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
31 changes: 10 additions & 21 deletions zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default Vue.extend({
},
data: function () {
return {
allEffects: {},
allTags: {},
allOwners: [] as MultiselectFilterData<number>,
allTypes: [] as MultiselectFilterData<number>,
Expand All @@ -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]]) => {
Expand Down Expand Up @@ -89,25 +87,16 @@ export default Vue.extend({
/>
</div>
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
<hr />
<LabelsFilter
title="Efekty kształcenia"
filterKey="effects-filter"
property="effects"
:allLabels="allEffects"
onClass="bg-info"
ref="effects-filter"
/>
</div>
<div class="col-md">
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
</div>
<MultiSelectFilter
filterKey="owner-filter"
property="owner"
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/timetable/assets/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export interface PersonDict {
}

export interface FilterDataJSON {
allEffects: KVDict;
allTags: KVDict;
allOwners: PersonDict;
allTypes: KVDict;
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/timetable/assets/store/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface CourseInfo {
id: number;
name: string;
url: string;
effects: Array<number>;
tags: Array<number>;
owner: number;
recommendedForFirstYear: boolean;
Expand Down
2 changes: 1 addition & 1 deletion zapisy/apps/enrollment/timetable/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
3 changes: 1 addition & 2 deletions zapisy/apps/offer/proposal/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
@admin.register(Proposal)
class ProposalAdmin(admin.ModelAdmin):
list_filter = ('status', 'semester', 'course_type', ('owner', admin.RelatedOnlyFieldListFilter),
'modified', 'tags', 'effects', ('courseinstance__semester',
admin.RelatedOnlyFieldListFilter))
'modified', 'tags', ('courseinstance__semester', admin.RelatedOnlyFieldListFilter))
list_display = ('name', 'owner', 'course_type', 'semester', 'status', 'modified',
'last_semester')
search_fields = ('name', 'name_en')
Expand Down
31 changes: 10 additions & 21 deletions zapisy/apps/offer/proposal/assets/components/CourseFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default Vue.extend({
},
data: function () {
return {
allEffects: {},
allTags: {},
allOwners: [] as MultiselectFilterData<number>,
allSemesters: [] as MultiselectFilterData<string>,
Expand All @@ -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]]) => {
Expand Down Expand Up @@ -104,25 +102,16 @@ export default Vue.extend({
/>
</div>
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
<hr />
<LabelsFilter
title="Efekty kształcenia"
filterKey="effects-filter"
property="effects"
:allLabels="allEffects"
onClass="bg-info"
ref="effects-filter"
/>
</div>
<div class="col-md">
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
</div>
<MultiSelectFilter
filterKey="owner-filter"
property="owner"
Expand Down
10 changes: 0 additions & 10 deletions zapisy/apps/offer/proposal/templates/proposal/proposal_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@
</td>
</tr>
{% endif %}
{% if course.effects.all %}
<tr>
<th>Grupy efektów kształcenia</th>
<td>
{% for effect in course.effects.all %}
<span class="badge bg-info me-2">{{ effect }}</span>
{% endfor %}
</td>
</tr>
{% endif %}
</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion zapisy/apps/offer/proposal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down
Loading
Loading