Commit 594f44ae0a971980d61c2c1868136ccce4ab78cb

Authored by Rohan Rangray
Exists in master

Merge branch 'master' of git.ucsd.edu:110swag/flashy-backend

Mergin study view fixes.

Showing 2 changed files Side-by-side Diff

flashcards/models.py View file @ 594f44a
... ... @@ -313,7 +313,6 @@
313 313 """
314 314 return self.whitelist.filter(email=user.email).exists()
315 315  
316   -
317 316 def enroll(self, user):
318 317 if user.sections.filter(pk=self.pk).exists():
319 318 raise ValidationError('User is already enrolled in this section')
320 319  
... ... @@ -339,10 +338,9 @@
339 338 0].short_start_time
340 339 else:
341 340 data = ''
342   - cache.set("section_%d_lecture_times" % self.pk, data, 24*60*60)
  341 + cache.set("section_%d_lecture_times" % self.pk, data, 24 * 60 * 60)
343 342 return data
344 343  
345   -
346 344 @property
347 345 def long_name(self):
348 346 return '%s %s (%s)' % (self.course_title, self.lecture_times, self.instructor)
... ... @@ -352,7 +350,8 @@
352 350 return '%s %s' % (self.department_abbreviation, self.course_num)
353 351  
354 352 def get_feed_for_user(self, user):
355   - qs = Flashcard.objects.filter(section=self).exclude(userflashcard__user=user).order_by('pushed')
  353 + qs = Flashcard.objects.filter(section=self).exclude(flashcardhide__user=user).exclude(
  354 + userflashcard__user=user).order_by('pushed')
356 355 return qs
357 356  
358 357 def get_cards_for_user(self, user):
flashcards/tests/test_api.py View file @ 594f44a
... ... @@ -358,6 +358,10 @@
358 358 response = self.client.get('/api/sections/{}/feed/'.format(self.section.pk))
359 359 self.assertEqual(response.status_code, HTTP_200_OK)
360 360 self.assertEqual(response.data[0]['id'], 1)
  361 + self.flashcard.hide_from(self.user)
  362 + response = self.client.get('/api/sections/{}/feed/'.format(self.section.pk))
  363 + self.assertEqual(response.status_code, HTTP_200_OK)
  364 + self.assertNotEqual(response.data[0]['id'], 1)
361 365  
362 366 def test_section_ordered_deck(self):
363 367 self.user.sections.add(self.section)