Beispiel #1
0
 def permission_check(self, action):
     if action == 'create':
         if not self.request.user.has_perm('core.change_application',
                                           Application(id=self.parent_id)):
             raise ModalPermissionException
     elif not self.request.user.has_perm('core.change_environment',
                                         Environment(id=self.id)):
         raise ModalPermissionException
Beispiel #2
0
        try:
            example_guid = objs[0].guid
        except:
            example_guid = 'GUID'
    auth_manager = request.auth_manager

    return render(request, 'manageDeveloper/query_list.html', locals())


def create(request):
    try:
        account = request.account
    except AttributeError, e:
        account = None

    hash_lenght = 40
    api_key = hashlib.sha224(str(random.random())).hexdigest()[0:hash_lenght]
    public_api_key = hashlib.sha224(str(
        random.random())).hexdigest()[0:hash_lenght]
    application = Application()
    application.auth_key = api_key
    application.public_auth_key = public_api_key
    application.valid = True
    application.expires_at = '2011-12-31 23:59:59Z'
    application.type = '00'
    application.account = account
    application.save()
    return HttpResponse('{"pApiKey":"%s", "pPublicApiKey":"%s"}' %
                        (api_key, public_api_key),
                        content_type='application/json')