コード例 #1
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
    def add_other_price(self):
        response = reply_object()
        try:
            object_model = get_object(self.cleaned_data["object_type"])
            object_db = object_model.objects.get\
                (pk = self.cleaned_data["object_id"])
        except:
            response["code"] = settings.APP_CODE["SYSTEM ERROR"]

        return response
コード例 #2
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
    def delete_object(self):
        response = reply_object()
        try:
            object_model = get_object(self.cleaned_data["object_type"])
            object_db = object_model.objects.get\
                (pk = self.cleaned_data["object_id"])
            object_db.delete()
            response["code"] = settings.APP_CODE["DELETED"]
        except:
            response["code"] = settings.APP_CODE["SYSTEM ERROR"]

        return response
コード例 #3
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
 def delete(self):
     """
     Delete function for named object form
     """
     response = reply_object()
     try:
         ItemObject = get_object(self.cleaned_data["named_object_type"])
         item_object = ItemObject.objects.get(pk = self.cleaned_data["named_object_id"])
         response["named_object_id"] = item_object.id
         item_object.delete()
         response["code"] = settings.APP_CODE["DELETED"]
     except:
         response["code"] = settings.APP_CODE["SYSTEM ERROR"]
     return response
コード例 #4
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
    def get_suggestions(self):
        response = reply_object()
        try:
            suggestions = []
            object_model = get_object(self.cleaned_data["object_type"])
            object_db = object_model.objects.filter\
                (name__icontains = self.cleaned_data["term"])

            for each_object in object_db:
                suggestions.append({"id" : each_object.id,
                                    "label" : each_object.name,
                                    "value" : each_object.name})
            return suggestions
        except:
            return []
        return response
コード例 #5
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
 def save(self):
     """
     Save function for named object form
     """
     response = reply_object()
     try:
         ItemObject = get_object(self.cleaned_data["named_object_type"])
         item_object, created = ItemObject.objects.get_or_create\
             (name = self.cleaned_data["name"])
         item_object.save()
         response["code"] = settings.APP_CODE["SAVED"]
         response["named_object"] = self.cleaned_data["name"]
         response["named_object_id"] = item_object.id
     except:
         response["code"] = settings.APP_CODE["SYSTEM ERROR"]
     return response
コード例 #6
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
 def update(self):
     """
     Update function for named object form
     """
     response = reply_object()
     try:
         ItemObject = get_object(self.cleaned_data["named_object_type"])
         item_object = ItemObject.objects.get\
             (pk = self.cleaned_data["named_object_id"])
         item_object.name = self.cleaned_data["name"]
         item_object.save()
         response["code"] = settings.APP_CODE["UPDATED"]
         response["named_object"] = self.cleaned_data["name"]
         response["named_object_id"] = item_object.id
     except:
         response["code"] = settings.APP_CODE["SYSTEM ERROR"]
     return response
コード例 #7
0
ファイル: forms.py プロジェクト: devasiajoseph/Retailer
    def untag(self):
        response = reply_object()
        try:
            t_model = get_object(self.cleaned_data["object_type"])
            t_object = t_model.objects.get(pk = self.cleaned_data["object_id"])
            tag = Tag.objects.get(pk = self.cleaned_data["tag_id"])
            if has_object_access(self.request, t_object):
                t_object.tags.remove(tag)
                response["code"] = settings.APP_CODE["CALLBACK"]
                tag_string = get_tagged_items(self.request, t_object)
                response["tagged_items"] = tag_string
            else:
                response["code"] = settings.APP_CODE["ACCESS DENIED"]
        except:
            response["code"] = settings.APP_CODE["SYSTEM ERROR"]

        return response