Esempio n. 1
0
    def test_page_with_same_config_for_anonymous_retrieved_on_next_visit(self):
        page = get_page(user=self.user, session=self.get_session(), for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        page_again = get_page(user=self.user, session=self.get_session(), for_update=True)

        self.assert_equals(page.layout, page_again.layout)
Esempio n. 2
0
    def test_anonymous_modifications_preserved_when_logging_in_with_same_session(self):
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        page_again = get_page(user=self.user, session=self.get_session())

        self.assert_equals(page.layout, page_again.layout)
        self.assert_not_equals(self.default_page.layout, page_again.layout)
Esempio n. 3
0
    def test_anonymous_page_destroyed_after_converting_to_user_page(self):
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        # converting to user page
        get_page(user=self.user, session=self.get_session())

        # default page now retrieved
        page = get_page(user=self.anonymous_user, session=self.get_session())
        self.assert_equals(self.default_page, page)
Esempio n. 4
0
    def test_anonymous_modifications_preserved_when_logging_in_with_same_session(
            self):
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        page_again = get_page(user=self.user, session=self.get_session())

        self.assert_equals(page.layout, page_again.layout)
        self.assert_not_equals(self.default_page.layout, page_again.layout)
Esempio n. 5
0
    def test_page_with_same_config_for_anonymous_retrieved_on_next_visit(self):
        page = get_page(user=self.user,
                        session=self.get_session(),
                        for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        page_again = get_page(user=self.user,
                              session=self.get_session(),
                              for_update=True)

        self.assert_equals(page.layout, page_again.layout)
Esempio n. 6
0
    def test_anonymous_page_destroyed_after_converting_to_user_page(self):
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        # converting to user page
        get_page(user=self.user, session=self.get_session())

        # default page now retrieved
        page = get_page(user=self.anonymous_user, session=self.get_session())
        self.assert_equals(self.default_page, page)
Esempio n. 7
0
    def test_user_page_takes_preference_over_modified_anonymous_page(self):
        # convert session page to user
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        get_page(user=self.user, session=self.get_session())

        # create modified anonymous page
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        # unmodified user page should be shown after next login
        page = get_page(user=self.user, session=self.get_session())
        self.assert_equals(self.default_page.layout, page.layout)
Esempio n. 8
0
    def test_user_page_takes_preference_over_modified_anonymous_page(self):
        # convert session page to user
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        get_page(user=self.user, session=self.get_session())

        # create modified anonymous page
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        page.add_widget(self.widget_u)
        page.save()

        # unmodified user page should be shown after next login
        page = get_page(user=self.user, session=self.get_session())
        self.assert_equals(self.default_page.layout, page.layout)
Esempio n. 9
0
    def test_anonymous_page_deleted_even_after_second_conversion(self):
        # this behaviour could change. See #3483

        # convert session page to user
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        get_page(user=self.user, session=self.get_session())

        # create modified anonymous page
        session_page = get_page(user=self.anonymous_user,
                                session=self.get_session(),
                                for_update=True)
        session_page.add_widget(self.widget_u)
        session_page.save()

        # log in again
        get_page(user=self.user, session=self.get_session())
        self.assert_equals(self.default_page.layout, page.layout)

        # our second modification of anonymous page preserved
        page = get_page(user=self.anonymous_user,
                        session=self.get_session(),
                        for_update=True)
        self.assert_equals(session_page.layout, page.layout)
Esempio n. 10
0
def add_rss_widget(request):

    creation_form = RSSCreationConfigForm(request.GET)

    if not creation_form.is_valid():
        return http.HttpResponseBadRequest('')

    page = get_page(request.user, request.session, for_update=True)

    url, title = creation_form.cleaned_data['feed']
    w, was_created =  RSSWidget.objects.get_or_create(
        feed_url=url,
        defaults={'title': title, 'slug': ''})

    page.add_widget(w)
    page.save()

    return http.HttpResponseRedirect(reverse('home_page'))
Esempio n. 11
0
def add_rss_widget(request):

    creation_form = RSSCreationConfigForm(request.GET)

    if not creation_form.is_valid():
        return http.HttpResponseBadRequest('')

    page = get_page(request.user, request.session, for_update=True)

    url, title = creation_form.cleaned_data['feed']
    w, was_created = RSSWidget.objects.get_or_create(feed_url=url,
                                                     defaults={
                                                         'title': title,
                                                         'slug': ''
                                                     })

    page.add_widget(w)
    page.save()

    return http.HttpResponseRedirect(reverse('home_page'))
Esempio n. 12
0
    def test_anonymous_page_deleted_even_after_second_conversion(self):
        # this behaviour could change. See #3483

        # convert session page to user
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        get_page(user=self.user, session=self.get_session())

        # create modified anonymous page
        session_page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        session_page.add_widget(self.widget_u)
        session_page.save()

        # log in again
        get_page(user=self.user, session=self.get_session())
        self.assert_equals(self.default_page.layout, page.layout)

        # our second modification of anonymous page preserved
        page = get_page(user=self.anonymous_user, session=self.get_session(), for_update=True)
        self.assert_equals(session_page.layout, page.layout)
Esempio n. 13
0
 def test_default_page_retrieved_for_anonymous_user(self):
     page = get_page(user=self.anonymous_user, session=self.get_session())
     self.assert_equals(self.default_page, page)
Esempio n. 14
0
 def test_user_page_cloned_with_default_layout(self):
     page = get_page(user=self.user, session=self.get_session(), for_update=True)
     self.assert_equals(self.default_page.layout, page.layout)
Esempio n. 15
0
 def test_new_page_for_authenticated_created_when_forced(self):
     page = get_page(user=self.user, session=self.get_session(), for_update=True)
     self.assert_not_equals(self.default_page, page)
Esempio n. 16
0
 def test_default_page_retrieved_for_authenticated_user(self):
     page = get_page(user=self.user, session=self.get_session())
     self.assert_equals(self.default_page, page)
Esempio n. 17
0
 def test_default_page_retrieved_for_anonymous_user(self):
     page = get_page(user=self.anonymous_user, session=self.get_session())
     self.assert_equals(self.default_page, page)
Esempio n. 18
0
 def test_default_page_retrieved_for_authenticated_user(self):
     page = get_page(user=self.user, session=self.get_session())
     self.assert_equals(self.default_page, page)
Esempio n. 19
0
 def test_new_page_for_authenticated_created_when_forced(self):
     page = get_page(user=self.user,
                     session=self.get_session(),
                     for_update=True)
     self.assert_not_equals(self.default_page, page)
Esempio n. 20
0
 def test_user_page_cloned_with_default_layout(self):
     page = get_page(user=self.user,
                     session=self.get_session(),
                     for_update=True)
     self.assert_equals(self.default_page.layout, page.layout)