Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yppf committed Aug 10, 2024
2 parents 4c14a9a + dc4733d commit 37fc890
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dormitory/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class DormitoryAgreementAdmin(admin.ModelAdmin):
class DormitoryAssignmentAdmin(admin.ModelAdmin):
list_display = ['dormitory', 'user', 'bed_id', 'time']
list_filter = ['bed_id', 'time']
search_fields = ['dormitory', *UserAdmin.suggest_search_fields('user'), 'time']
search_fields = ['dormitory__id', *UserAdmin.suggest_search_fields('user'), 'time']
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
# 创建一个survey
survey = Survey.objects.create(
title = "宿舍生活习惯调研",
title = "宿舍生活习惯调研-2023",
description = "根据问卷情况对宿舍进行分配",
status = Survey.Status.PUBLISHED, # 传参
creator_id = 1, # 传参
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
# 创建一个survey
survey = Survey.objects.create(
title = "宿舍生活习惯调研",
title = "宿舍生活习惯调研-2024",
description = "根据问卷情况对宿舍进行分配",
status = Survey.Status.PUBLISHED, # 传参
creator_id = 1, # 传参
Expand Down
7 changes: 4 additions & 3 deletions dormitory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
DormitoryAssignmentSerializer, DormitorySerializer,
AgreementSerializerFixme, AgreementSerializer)
from questionnaire.models import AnswerSheet, AnswerText, Survey
from semester.api import next_semester


class DormitoryViewSet(viewsets.ReadOnlyModelViewSet):
Expand Down Expand Up @@ -47,7 +48,7 @@ class DormitoryRoutineQAView(ProfileTemplateView):
need_prepare = False

def get_survey(self):
return Survey.objects.get(title='宿舍生活习惯调研')
return Survey.objects.get(title=f'宿舍生活习惯调研-{next_semester().year}')

def get(self):
survey = self.get_survey()
Expand Down Expand Up @@ -98,14 +99,14 @@ def show_dorm_assign(self):
roommates = [NaturalPerson.objects.get_by_user(assign.user)
for assign in dorm_assignment.exclude(user=user)]
self.extra_context.update(
dorm_assign=True,
dorm_assigned=True,
name=user.get_full_name(),
dorm_id=assignment.dormitory.id,
bed_id=assignment.bed_id,
roommates=roommates,
)
except DormitoryAssignment.DoesNotExist:
self.extra_context.update(dorm_assign=False)
self.extra_context.update(dorm_assigned=False)

class AgreementView(ProfileTemplateView):
template_name = 'dormitory/agreement.html'
Expand Down

0 comments on commit 37fc890

Please sign in to comment.