Commit 148b7e62d21d370011b87b073ee6e6ba30d55349
1 parent
ddba4aeba1
Exists in
master
Attempted fix for /deck/ notifications.
Showing 3 changed files with 5 additions and 5 deletions Side-by-side Diff
flashcards/models.py
View file @
148b7e6
... | ... | @@ -110,7 +110,7 @@ |
110 | 110 | import flashcards.notifications |
111 | 111 | |
112 | 112 | flashcards.notifications.notify_score_change(flashcard) |
113 | - flashcards.notifications.notify_pull(flashcard) | |
113 | + flashcards.notifications.notify_pull(flashcard, self) | |
114 | 114 | |
115 | 115 | def unpull(self, flashcard): |
116 | 116 | if not self.is_in_section(flashcard.section): |
flashcards/notifications.py
View file @
148b7e6
... | ... | @@ -20,11 +20,10 @@ |
20 | 20 | ) |
21 | 21 | message = RedisMessage(ws_message) |
22 | 22 | redis_publisher.publish_message(message) |
23 | - notify_pull(flashcard) | |
24 | 23 | |
25 | 24 | |
26 | -def notify_pull(flashcard): | |
27 | - redis_publisher = RedisPublisher(facility='deck/%d' % flashcard.section_id, users=[SELF]) | |
25 | +def notify_pull(flashcard, user): | |
26 | + redis_publisher = RedisPublisher(facility='deck/%d' % flashcard.section_id, users=[user]) | |
28 | 27 | ws_message = JSONRenderer().render( |
29 | 28 | {'event_type': 'pull_card', 'flashcard': serializers.FlashcardSerializer(flashcard).data} |
30 | 29 | ) |
flashcards/views.py
View file @
148b7e6
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | IsAuthenticatedAndConfirmed |
7 | 7 | from flashcards.models import Section, User, Flashcard, FlashcardHide, UserFlashcardQuiz, \ |
8 | 8 | FlashcardAlreadyPulledException, FlashcardNotInDeckException |
9 | -from flashcards.notifications import notify_new_card | |
9 | +from flashcards.notifications import notify_new_card, notify_pull | |
10 | 10 | from flashcards.serializers import SectionSerializer, UserUpdateSerializer, RegistrationSerializer, UserSerializer, \ |
11 | 11 | PasswordResetSerializer, PasswordResetRequestSerializer, EmailPasswordSerializer, FlashcardSerializer, \ |
12 | 12 | FlashcardUpdateSerializer, QuizRequestSerializer, QuizResponseSerializer, \ |
... | ... | @@ -317,6 +317,7 @@ |
317 | 317 | flashcard = Flashcard.objects.create(**data) |
318 | 318 | self.perform_create(flashcard) |
319 | 319 | notify_new_card(flashcard) |
320 | + notify_pull(flashcard, request.user) | |
320 | 321 | headers = self.get_success_headers(data) |
321 | 322 | request.user.pull(flashcard) |
322 | 323 | response_data = FlashcardSerializer(flashcard).data |