Beispiel #1
0
    def read(self, request, id=None):
        ready_data_true =  {'success': True }
        ready_data_false = {'success': False}

        if not request.user.is_authenticated():
            ready_data_false["error"] = "Authorization is failed"
            return ready_data_false

        try:
            currentProfile = Profile.getProfile( request.user)

            start = 0
            limit = 1000 # will most likely get all vendors
            try:
                start    = int(request.GET['start'])
                limit    = int(request.GET['limit'])
            except Exception:
                pass # do nothing default values for start and limit already set
            search = None

            return Vendor.getVendors(currentProfile.parent_user, id, search, start, limit)

        except Exception, err:
            logger.error(err)
            ready_data_false['errors'] = err
            return ready_data_false
Beispiel #2
0
    def create(self, request):
        ready_data_true =  {'success': True }
        ready_data_false = {'success': False}

        if not request.user.is_authenticated():
            ready_data_false["error"] = "Authorization is failed"
            return ready_data_false

        try:
            ext_posted_data = simplejson.loads(request.POST.get('items'))
            attrs = self.flatten_dict(ext_posted_data)

            return Vendor.createVendor(request.user, attrs)
        except Exception, err:
            logger.error(err)
            ready_data_false['errors'] = err
            return ready_data_false