def setUpClass(cls): super(TestOpenBookmarks, cls).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()
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()
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()
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)
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))