Пример #1
0
    def setUpClass(cls):
        super(TestOpenBookmarks, cls).setUpClass()

        cls.tester = create_request_user('bookmark_tester', 'password')

        bookmark_form = BookmarkForm({
            'name': 'plan page',
            'url': 'http://localhost/plan/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_1 = bookmark_form.save()

        bookmark_form = BookmarkForm({
            'name': 'case page',
            'url': 'http://localhost/case/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_2 = bookmark_form.save()

        bookmark_form = BookmarkForm({
            'name': 'run page',
            'url': 'http://localhost/run/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_3 = bookmark_form.save()
Пример #2
0
    def setUpClass(cls):
        super().setUpClass()

        cls.tester = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')

        bookmark_form = BookmarkForm({
            'name': 'plan page',
            'url': 'http://localhost/plan/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_1 = bookmark_form.save()

        bookmark_form = BookmarkForm({
            'name': 'case page',
            'url': 'http://localhost/case/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_2 = bookmark_form.save()

        bookmark_form = BookmarkForm({
            'name': 'run page',
            'url': 'http://localhost/run/1/',
            'user': cls.tester.pk,
            'a': 'add',
        })
        bookmark_form.is_valid()
        cls.bookmark_3 = bookmark_form.save()
Пример #3
0
        def add(self):
            form = BookmarkForm(request.GET)
            if not form.is_valid():
                ajax_response = {'rc': 1, 'response': form.errors.as_text()}
                return http.JsonResponse(ajax_response)

            form.save()
            return http.JsonResponse(self.ajax_response)
Пример #4
0
        def add(self):
            form = BookmarkForm(request.REQUEST)
            if not form.is_valid():
                ajax_response = {
                    'rc': 1,
                    'response': form.errors.as_text(),
                }
                return HttpResponse(simplejson.dumps(ajax_response))

            form.save()
            return HttpResponse(simplejson.dumps(self.ajax_response))
Пример #5
0
 def render_form(self):
     query = request.GET.copy()
     query['a'] = 'add'
     form = BookmarkForm(initial=query)
     form.populate(user=request.user)
     return HttpResponse(form.as_p())