Beispiel #1
0
def mark_hotspot_as_read(
    request: HttpRequest, user: UserProfile, hotspot: str = REQ()
) -> HttpResponse:
    if hotspot not in ALL_HOTSPOTS:
        raise JsonableError(_("Unknown hotspot: {}").format(hotspot))
    do_mark_hotspot_as_read(user, hotspot)
    return json_success()
Beispiel #2
0
 def test_do_mark_hotspot_as_read(self) -> None:
     user = self.example_user("hamlet")
     do_mark_hotspot_as_read(user, "intro_compose")
     self.assertEqual(
         list(UserHotspot.objects.filter(user=user).values_list("hotspot", flat=True)),
         ["intro_compose"],
     )
Beispiel #3
0
def mark_hotspot_as_read(
    request: HttpRequest, user: UserProfile, hotspot: str = REQ(json_validator=check_string)
) -> HttpResponse:
    if hotspot not in ALL_HOTSPOTS:
        return json_error(_("Unknown hotspot: {}").format(hotspot))
    do_mark_hotspot_as_read(user, hotspot)
    return json_success()
Beispiel #4
0
 def test_all_intro_hotspots_done(self) -> None:
     with self.settings(TUTORIAL_ENABLED=True):
         self.assertNotEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
         for hotspot in INTRO_HOTSPOTS:
             do_mark_hotspot_as_read(self.user, hotspot)
         self.assertEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
         self.assertEqual(get_next_hotspots(self.user), [])
Beispiel #5
0
 def test_all_done(self):
     # type: () -> None
     self.assertNotEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
     for hotspot in ALL_HOTSPOTS:
         do_mark_hotspot_as_read(self.user, hotspot)
     self.assertEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
     self.assertEqual(get_next_hotspots(self.user), [])
Beispiel #6
0
 def test_some_done_some_not(self):
     # type: () -> None
     do_mark_hotspot_as_read(self.user, 'intro_reply')
     do_mark_hotspot_as_read(self.user, 'intro_compose')
     hotspots = get_next_hotspots(self.user)
     self.assertEqual(len(hotspots), 1)
     self.assertEqual(hotspots[0]['name'], 'intro_streams')
Beispiel #7
0
 def test_some_done_some_not(self):
     # type: () -> None
     do_mark_hotspot_as_read(self.user, 'intro_reply')
     do_mark_hotspot_as_read(self.user, 'intro_compose')
     hotspots = get_next_hotspots(self.user)
     self.assertEqual(len(hotspots), 1)
     self.assertEqual(hotspots[0]['name'], 'intro_streams')
Beispiel #8
0
 def test_do_mark_hotspot_as_read(self) -> None:
     user = self.example_user('hamlet')
     do_mark_hotspot_as_read(user, 'intro_compose')
     self.assertEqual(
         list(
             UserHotspot.objects.filter(user=user).values_list('hotspot',
                                                               flat=True)),
         ['intro_compose'])
Beispiel #9
0
 def test_all_done(self) -> None:
     self.assertNotEqual(self.user.tutorial_status,
                         UserProfile.TUTORIAL_FINISHED)
     for hotspot in ALL_HOTSPOTS:
         do_mark_hotspot_as_read(self.user, hotspot)
     self.assertEqual(self.user.tutorial_status,
                      UserProfile.TUTORIAL_FINISHED)
     self.assertEqual(get_next_hotspots(self.user), [])
Beispiel #10
0
 def test_do_mark_hotspot_as_read(self) -> None:
     user = self.example_user('hamlet')
     do_mark_hotspot_as_read(user, 'intro_compose')
     self.assertEqual(list(UserHotspot.objects.filter(user=user)
                           .values_list('hotspot', flat=True)), ['intro_compose'])
Beispiel #11
0
 def test_some_done_some_not(self) -> None:
     do_mark_hotspot_as_read(self.user, "intro_reply")
     do_mark_hotspot_as_read(self.user, "intro_compose")
     hotspots = get_next_hotspots(self.user)
     self.assertEqual(len(hotspots), 1)
     self.assertEqual(hotspots[0]["name"], "intro_streams")
Beispiel #12
0
def mark_hotspot_as_read(request, user, hotspot=REQ(validator=check_string)):
    # type: (HttpRequest, UserProfile, str) -> HttpResponse
    if hotspot not in ALL_HOTSPOTS:
        return json_error(_('Unknown hotspot: %s') % (hotspot,))
    do_mark_hotspot_as_read(user, hotspot)
    return json_success()