Beispiel #1
0
 def handle(self, *args, **options):
     data = requests.get('https://onmyoji.rapospectre.com/s/file/scene_datiangou.json', verify=False).content
     json_data = json.loads(data)
     num = 0
     for item in json_data:
         scene = Scene(name=item.get('scene_name'))
         scene.save()
         for itm in item.get('team_list'):
             team = Team(name=itm.get('name'), index=itm.get('index'), belong=scene)
             team.save()
             for mitm in itm.get('monsters'):
                 hs = Hellspawn.objects.get(name=mitm.get('name'))
                 Membership(hellspawn=hs, count=mitm.get('count'), team=team).save()
    def create(self, request):
        if not 'name' in request.POST:
            return rc.BAD_REQUEST

        if Team.objects.filter(name=request.POST['name']):
            return rc.DUPLICATE_ENTRY

        data = {}
        data['name'] = request.POST['name']
        data['created_by'] = request.user

        if 'description' in request.POST:
            data['description'] = request.POST['description']

        if 'password' in request.POST and request.POST['password'].strip():
            data['public'] = False
            data['password'] = request.POST['password']

        team = Team(**data)
        team.save()
        return rc.CREATED
Beispiel #3
0
    def create(self, request):
        if not "name" in request.POST:
            return rc.BAD_REQUEST

        if Team.objects.filter(name=request.POST["name"]):
            return rc.DUPLICATE_ENTRY

        data = {}
        data["name"] = request.POST["name"]
        data["created_by"] = request.user

        if "description" in request.POST:
            data["description"] = request.POST["description"]

        if "password" in request.POST and request.POST["password"].strip():
            data["public"] = False
            data["password"] = request.POST["password"]

        team = Team(**data)
        team.save()
        return rc.CREATED
Beispiel #4
0
    def setUp(self):
        user = User.objects.create_user('existing_user',
                                        '*****@*****.**',
                                        'donthackmebro')

        user.save()

        ownsnoteam = User.objects.create_user('ownsnoteam',
                                              '*****@*****.**',
                                              'donthackmeeither')
        ownsnoteam.save()

        public_team = Team(name='public test team',
                           description='test me, dude',
                           created_by=user,
                           public=True)
        public_team.save()
        public_team.members.add(ownsnoteam)

        public_lolcats = Team(name='LOLcats',
                              description='internet memes FTW!',
                              created_by=user,
                              public=True)
        public_lolcats.save()

        private_lolcats = Team(name='existing_user_LOLcats',
                               description='adult lolcat content',
                               created_by=user,
                               public=False,
                               password='******')
        private_lolcats.save()
        private_lolcats.members.add(ownsnoteam)

        self.auth_client = BasicAuthClient('existing_user', 'donthackmebro')
Beispiel #5
0
    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')