Exemple #1
0
 def save(self):
     # print("mro:", PageProxyModel.__mro__)
     """
     <class 'pylucid_migration.models.cms_pagemodel.PageProxyModel'>
     <class 'cms.models.pagemodel.Page'>
     <class 'mptt.models.MPTTModel'>
     <class 'django.db.models.base.Model'>
     <class 'object'>
     """
     Model.save(self)
Exemple #2
0
 def all(self, request, model):
     if request.method == 'GET':
         result = Model.__getattribute__(models, model)()
         resource = Model.__getattribute__(resources, model + 'Resource')
         Serializer = resource(type(result).objects.all(), many=True)
         data = encrypt(Serializer.data)
         return JsonResponse({
             'token': data['token'],
             'key': data['key']
         },
                             safe=False)
Exemple #3
0
 def data(self, request, model, id):
     if request.method == 'GET':
         result = Model.__getattribute__(models, model)()
         resource = Model.__getattribute__(resources, model + 'Resource')
         Serializer = resource(type(result).objects.filter(id=id),
                               many=True)
         data = {k: v for item in Serializer.data for k, v in item.items()}
         data = encrypt(data)
         return JsonResponse({
             'token': data['token'],
             'key': data['key']
         },
                             safe=False)
Exemple #4
0
 def test_site_and_short_url_are_unique_together(self):
     l1 = Link(destination_url="http://example.com", short_url="foobarbaz", site=self.site)
     l2 = Link(destination_url="http://example.com", short_url="foobarbaz", site=self.site)
     Model.save(l1)
     Model.save(l2)
Exemple #5
0
 def __init__(self, *args, **kwargs):
     Model.__init__(self, *args, **kwargs)
     try:
         self._calculate_boundaries()
     except:
         llogger.exception("Error calculating boundaries for %s " % self)
Exemple #6
0
 def add(self, request, model):
     if request.method == "POST":
         data = json.loads(request.body)
         result = Model.__getattribute__(models, model)()
         type(result).objects.create(**data)
         return HttpResponse(request)
Exemple #7
0
 def update(self, request, model, id):
     if request.method == "POST":
         data = json.loads(request.body)
         result = Model.__getattribute__(models, model)()
         type(result).objects.filter(id=id).update(**data)
         return HttpResponse(request)
 def relate_object_to_user(self, object_ref: Model):
     logger.debug(f"attaching user id {self.user_pk} to model {object_ref}")
     object_ref.user_pk = self.user_pk
 def post_handle_object(self, parent_ref: str, object_ref: Model, data):
     if RELATE_TO_USER:
         self.relate_object_to_user(object_ref)
     object_ref.save()
     return object_ref