-
Notifications
You must be signed in to change notification settings - Fork 10
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
1580 temat pracy dyplomowej nie traci głosów #1646
base: master-dev
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,11 +169,29 @@ def notify_board_members_about_voting(sender: Thesis, **kwargs) -> None: | |
users = [voter.user for voter in all_voters if voter not in accepting_voters] | ||
target = reverse('theses:selected_thesis', args=[thesis.id]) | ||
|
||
operation = 'create' | ||
if 'operation' in kwargs: | ||
operation = kwargs['operation'] | ||
|
||
if operation == 'modify': | ||
if 'notify_only_voted' in kwargs and kwargs['notify_only_voted']: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tu podobnie, zapewnijmy, żeby ten argument zawsze był w There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usunąłem zmienna operation i dodałem flage |
||
already_voted = [v.owner for v in thesis.thesis_votes.all() if v.vote != ThesisVote.NONE] | ||
users = [voter.user for voter in already_voted] | ||
notify_selected_users( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chciałbym, żeby w kodzie po zmianach dalej było dokładnie jedno wywołanie tej funkcji. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotowe |
||
users, | ||
Notification(get_id(), get_time(), | ||
NotificationType.THESIS_VOTING_HAS_BEEN_ACTIVATED, { | ||
'title': thesis.title, | ||
'status': 'zmodyfikowanym', | ||
}, target)) | ||
return | ||
|
||
notify_selected_users( | ||
users, | ||
Notification(get_id(), get_time(), | ||
NotificationType.THESIS_VOTING_HAS_BEEN_ACTIVATED, { | ||
'title': thesis.title | ||
'title': thesis.title, | ||
'status': 'nowym', | ||
}, target)) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ class ThesisVote(models.IntegerChoices): | |
NONE = 1, "brak głosu" | ||
REJECTED = 2, "odrzucona" | ||
ACCEPTED = 3, "zaakceptowana" | ||
|
||
|
||
SIGNIFICANT_FIELDS = ['title', 'supporting_advisor', 'kind', 'max_number_of_students', 'description'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dobry pomysł żeby bardziej wyeksponować tę listę, ale ona nie pasuje do tego pliku. Zostawiłbym ją jednak w There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotowe |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -107,9 +107,22 @@ def save(self, *args, **kwargs): | |||||
""" | ||||||
old = self.pk and type(self).objects.get(pk=self.pk) | ||||||
super(Thesis, self).save(*args, **kwargs) | ||||||
if not old or (old.status != ThesisStatus.BEING_EVALUATED and self.status == ThesisStatus.BEING_EVALUATED): | ||||||
if not old: | ||||||
self.thesis_votes.filter(vote__in=[ThesisVote.ACCEPTED, ThesisVote.REJECTED]).update(vote=ThesisVote.NONE) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Czy ta instrukcja ma znaczenie? Dla nowego tematu nie będzie (nietrywialnych) głosów. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instrukcja do usuwania głosów usunięta, faktycznie dla nowych tematów nie miała ona sensu |
||||||
thesis_voting_activated.send(sender=self.__class__, instance=self) | ||||||
|
||||||
if old and old.status != ThesisStatus.BEING_EVALUATED and self.status == ThesisStatus.BEING_EVALUATED: | ||||||
# in case of new thesis titile send notification to all board members | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotowe |
||||||
self.thesis_votes.filter(vote__in=[ThesisVote.ACCEPTED, ThesisVote.REJECTED]).update(vote=ThesisVote.NONE) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zdaje się, że w tej gałęzi nie ma znaczenia kolejność "resetowania" głosów oraz wysłania powiadomienia - a gdyby ją odwrócić, to "resetowanie" można postawić w ogóle za instrukcją warunkową. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wydaje mi się, że nie możemy wyciągnąć tego poza instrukcję warunkową, bo nie zawsze chcemy resetować głosy przy zapisie modelu. Proszę mnie poprawić jeśli się mylę. |
||||||
thesis_voting_activated.send(sender=self.__class__, instance=self, operation='modify') | ||||||
if old and (old.status == ThesisStatus.BEING_EVALUATED and | ||||||
self.status == ThesisStatus.BEING_EVALUATED and | ||||||
self.significant_field_changed): | ||||||
# send notification only to the board memebers who already accepted the thesis | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotowe |
||||||
thesis_voting_activated.send(sender=self.__class__, instance=self, operation='modify', | ||||||
notify_only_voted=True) | ||||||
self.thesis_votes.filter(vote__in=[ThesisVote.ACCEPTED, ThesisVote.REJECTED]).update(vote=ThesisVote.NONE) | ||||||
|
||||||
def get_accepted_votes(self): | ||||||
return len(self.thesis_votes.filter(vote=ThesisVote.ACCEPTED)) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tak w ogóle, to jakie są możliwe wartości tego kwargu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A, on wcale nie jest biblioteczny? To na pewno nie chciałbym wprowadzać rozróżniania pomiędzy dwoma możliwościami przez sprawdzanie, czy jakiś napis jest taki a nie inny. Póki to są faktycznie dwie możliwości, to można to opędzić wartością boolowską (o nazwie np.
is_new
, jeśli nie wpadniemy na nic zgrabniejszego); gdyby było więcej scenariuszy, to należałoby zadeklarować jakiegoś enum-a.Ponadto skoro mamy nad nim pełną kontrolę, to zamiast zaszywać tutaj jakieś wartości domyślne, to podawajmy go jawnie wysyłając sygnał – przy trzech wywołaniach nawet nie oszczędzamy napisanych znaków.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zmienione na flage is_new