def _create_with_common_fields(self, request): qdict = request.POST dragable = Dragable.objects.get(hash=qdict['dragable']) annotation = Annotation() annotation.dragable = dragable annotation.created_by = request.user for field in ('hash', 'type'): setattr(annotation, field, qdict[field]) return annotation
def _create_with_common_fields(self, request): qdict = request.POST dragable = Dragable.objects.get(hash=qdict["dragable"]) annotation = Annotation() annotation.dragable = dragable annotation.created_by = request.user for field in ("hash", "type"): setattr(annotation, field, qdict[field]) return annotation
def setUp(self): user = User.objects.create_user('testuser', '*****@*****.**', 'donthackmebro') user.save() user2 = User.objects.create_user('testuser2', '*****@*****.**', 'donthackmebro') user2.save() public_team = Team(name='public test team', description='test me, dude', created_by=user, public=True) public_team.save() public_team2 = Team(name='public test team 2', description='test me, too', created_by=user2, public=True) public_team2.save() public_team3 = Team(name='public test team 3', description='test me, also', created_by=user2, public=False, password='******') public_team3.save() public_team3.members.add(user) dragable = Dragable() dragable.hash = '23425' dragable.team = public_team dragable.created_by = user dragable.url = 'http://www.example.com' dragable.title = 'test dragable 1' dragable.text = 'foo bar baz' dragable.xpath = 'foo/bar/baz' dragable.save() dragable2 = Dragable() dragable2.hash = '4711' dragable2.team = public_team2 dragable2.created_by = user2 dragable2.url = 'http://www.example2.com' dragable2.title = 'test dragable 2' dragable2.text = 'spam eggs spamneggs' dragable2.xpath = 'spam/eggs/ni!' dragable2.save() dragable3 = Dragable() dragable3.hash = '12345' dragable3.team = public_team3 dragable3.created_by = user2 dragable3.url = 'http://www.example3.com' dragable3.title = 'test dragable 3' dragable3.text = 'fu fa fi' dragable3.xpath = 'fi/fa/fu' dragable3.save() note_annotation1 = Annotation() note_annotation1.type = 'note' note_annotation1.hash = 'note_ann1' note_annotation1.dragable = dragable note_annotation1.created_by = user note_annotation1.note = 'this is the first note annotation. evar!!' note_annotation1.save() url_annotation1 = Annotation() url_annotation1.type = 'url' url_annotation1.hash = 'url_ann1' url_annotation1.dragable = dragable url_annotation1.created_by = user url_annotation1.url = 'http://example.com' url_annotation1.save() url_annotation2 = Annotation() url_annotation2.type = 'url' url_annotation2.hash = 'url_ann2' url_annotation2.dragable = dragable2 url_annotation2.created_by = user2 url_annotation2.url = 'http://google.com' url_annotation2.save() self.client = BasicAuthClient('testuser', 'donthackmebro')