Commit 2f415807e1163b7e38ab262502e23820b82aed39
Exists in
master
Merge branch 'master' of git.ucsd.edu:110swag/flashy-backend
mering'
Showing 4 changed files Side-by-side Diff
flashcards/models.py
View file @
2f41580
... | ... | @@ -351,9 +351,8 @@ |
351 | 351 | |
352 | 352 | flashcards.pushes.push_deck_event('card_hidden', self, user) |
353 | 353 | if self.is_in_deck(user): user.unpull(self) |
354 | - hide, created = FlashcardHide.objects.get_or_create(user=user, flashcard=self, reason=reason) | |
355 | - if not created: | |
356 | - raise FlashcardAlreadyHiddenException("The card has already been hidden.") | |
354 | + hide, created = FlashcardHide.objects.get_or_create(user=user, flashcard=self) | |
355 | + hide.reason = reason | |
357 | 356 | hide.save() |
358 | 357 | |
359 | 358 | def unhide_by_user(self, user, reason=None): |
... | ... | @@ -373,7 +372,7 @@ |
373 | 372 | return delta.total_seconds() |
374 | 373 | |
375 | 374 | z = 0 |
376 | - rate = 1.0 / 3600 | |
375 | + rate = 1.0 / 120 | |
377 | 376 | for vote in self.userflashcard_set.iterator(): |
378 | 377 | t = seconds_since_epoch(vote.pulled) |
379 | 378 | u = max(z, rate * t) |
flashcards/views.py
View file @
2f41580
... | ... | @@ -245,7 +245,19 @@ |
245 | 245 | request.user.set_registration_id(serializer.validated_data['registration_id']) |
246 | 246 | return Response(status=HTTP_204_NO_CONTENT) |
247 | 247 | |
248 | +@api_view(['POST']) | |
249 | +def unsubscribe(request, format=None): | |
250 | + """ | |
251 | + Remove the user with the passed in registration token | |
252 | + --- | |
253 | + request_serializer: SubscribeViewSerializer | |
254 | + """ | |
255 | + serializer = SubscribeViewSerializer(data=request.data) | |
256 | + serializer.is_valid(raise_exception=True) | |
257 | + request.user.set_registration_id(None) | |
258 | + return Response(status=HTTP_204_NO_CONTENT) | |
248 | 259 | |
260 | + | |
249 | 261 | @api_view(['POST']) |
250 | 262 | def login(request): |
251 | 263 | """ |
... | ... | @@ -445,7 +457,6 @@ |
445 | 457 | |
446 | 458 | user_flashcard_quiz = UserFlashcardQuiz(user_flashcard=user_flashcard, blanked_word=blanked_word) |
447 | 459 | user_flashcard_quiz.save() |
448 | - | |
449 | 460 | response = QuizResponseSerializer(instance=user_flashcard_quiz, mask=mask) |
450 | 461 | log_event(request, response.data) |
451 | 462 | return Response(response.data, status=HTTP_200_OK) |
flashy/urls.py
View file @
2f41580
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | from django.contrib import admin |
3 | 3 | from flashcards.views import SectionViewSet, UserDetail, FlashcardViewSet, UserSectionListView, request_password_reset, \ |
4 | 4 | reset_password, logout, login, register, UserFlashcardQuizViewSet, \ |
5 | - resend_confirmation_email, verify_email, subscribe | |
5 | + resend_confirmation_email, verify_email, subscribe, unsubscribe | |
6 | 6 | from flashy.frontend_serve import serve_with_default |
7 | 7 | from flashy.settings import DEBUG, IN_PRODUCTION |
8 | 8 | from rest_framework.routers import DefaultRouter |
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | url(r'^api/login/$', login), |
21 | 21 | url(r'^api/logout/$', logout), |
22 | 22 | url(r'^api/subscribe/$', subscribe), |
23 | + url(r'^api/unsubscribe/$', unsubscribe), | |
23 | 24 | url(r'^api/me/sections/', UserSectionListView.as_view()), |
24 | 25 | url(r'^api/resend_confirmation_email/', resend_confirmation_email), |
25 | 26 | url(r'^api/verify_email/', verify_email), |