Esempio n. 1
0
 def destroy(self, request, pk=None):
     try:
         queryset = OutletStore.objects.all().filter(is_active=1)
         outletstoreObject = get_object_or_404(queryset, pk=pk)
         data = {"is_active": settings.IS_INACTIVE}
         serializer = OutletStoreSerializer(outletstoreObject,
                                            data=data,
                                            partial=True)
         if serializer.is_valid():
             serializer.save(updated=datetime.now())
             outletContact = OutletStoreContact.objects.filter(
                 is_active=1, outlet_store_id=outletstoreObject.id)
             for item in outletContact:
                 outletContact_reply = OutletStoreContactReply.objects.filter(
                     outlet_store_contact_id=item.id).filter(is_active=1)
                 if (outletContact_reply):
                     CommonFuntion.update_active(outletContact_reply)
                     self.update_active(outletContact)
             outletMedia = OutletStoreMedia.objects.filter(
                 is_active=1, outlet_store_id=outletstoreObject.id)
             self.update_active(outletMedia)
         return Response(CommonFuntion.resultResponse(
             True, serializer.data, MessageCode.OT008.value, ""),
                         status=status.HTTP_200_OK)
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.OT009.value, serializer.errors),
                         status=status.HTTP_404_BAD_REQUEST)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.OT007.value, serializer.errors),
                         status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
 def create(self, request):
     request.data['create_user_id'] = request.user.id
     serializer = EventSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save(is_active=settings.IS_ACTIVE, created=datetime.now(), updated=datetime.now())
         return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.EV004.value, ""), status=status.HTTP_201_CREATED)
     return Response(CommonFuntion.resultResponse(False, "", MessageCode.EV005.value, serializer.errors), status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
 def retrieve(self, request, pk=None):
     try:
         queryset = Event.objects.all().filter(is_active=1)
         outletstoreObject = get_object_or_404(queryset, pk=pk)
         serializer = EventSerializer(outletstoreObject)
         return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.EV002.value, ""), status=status.HTTP_200_OK)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(False, "", MessageCode.EV003.value, ""), status=status.HTTP_404_NOT_FOUND)
Esempio n. 4
0
 def update(self, request, pk=None):
     request.data['create_user_id'] = request.user.id
     queryset = Event.objects.all()
     event_obj = get_object_or_404(queryset, pk=pk)
     serializer = EventSerializer(event_obj, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.EV006.value, ""), status=status.HTTP_200_OK)
     return Response(CommonFuntion.resultResponse(False, "", MessageCode.EV007.value, serializer.errors), status=status.HTTP_400_BAD_REQUEST)
Esempio n. 5
0
 def put(self, request, pk=None, *args, **kwargs):
     try:
         request.data['create_user_id'] = request.user.id
         queryset = OrderModelHouse.objects.all().filter(is_active=1)
         orderModelObject = get_object_or_404(queryset, pk=pk)
         serializer = OrderModelHouseSerializer(orderModelObject, data=request.data, partial=True)
         if serializer.is_valid():
             serializer.save(is_active=settings.IS_ACTIVE, created=datetime.now(), updated=datetime.now())
             return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.OMH006.value, ""), status=status.HTTP_200_OK)
         return Response(CommonFuntion.resultResponse(False, "", MessageCode.OMH007.value, serializer.errors), status=status.HTTP_400_BAD_REQUEST)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(False, "", MessageCode.OMH007.value, ""), status=status.HTTP_404_NOT_FOUND)
Esempio n. 6
0
 def destroy(self, request, pk=None):
     try:
         queryset = OrderModelHouse.objects.all().filter(is_active=1)
         orderModelObject = get_object_or_404(queryset, pk=pk)
         data = {"is_active": settings.IS_INACTIVE}
         serializer = OrderModelHouseSerializer(orderModelObject, data=data, partial=True)
         if serializer.is_valid():
             serializer.save(updated=datetime.now())
             return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.OMH008.value, ""), status=status.HTTP_200_NO_CONTENT)
         return Response(CommonFuntion.resultResponse(False, "", MessageCode.OMH009.value, serializer.errors), status=status.HTTP_404_BAD_REQUEST)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(False, "", MessageCode.OMH007.value, ""), status=status.HTTP_404_NOT_FOUND)
Esempio n. 7
0
 def update(self, request, pk=None):
     try:
         queryset = ExhibitionTag.objects.all()
         event_obj = get_object_or_404(queryset, pk=pk)
         serializer = ExhibitionTagSerializer(event_obj, data=request.data)
         if serializer.is_valid():
             serializer.save()
             return Response(CommonFuntion.resultResponse(
                 True, serializer.data, MessageCode.EXT006.value, ""),
                             status=status.HTTP_200_OK)
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.EXT007.value, serializer.errors),
                         status=status.HTTP_400_BAD_REQUEST)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.EXT003.value, ""),
                         status=status.HTTP_404_NOT_FOUND)
Esempio n. 8
0
 def update(self, request, pk=None):
     request.data['create_user_id'] = request.user.id
     queryset = OutletStore.objects.all().filter(is_active=1)
     outletstoreObject = get_object_or_404(queryset, pk=pk)
     serializer = OutletStoreSerializer(outletstoreObject,
                                        data=request.data)
     if serializer.is_valid():
         serializer.save(is_active=settings.IS_ACTIVE,
                         created=datetime.now(),
                         updated=datetime.now())
         return Response(CommonFuntion.resultResponse(
             True, serializer.data, MessageCode.OT006.value, ""),
                         status=status.HTTP_200_OK)
     return Response(CommonFuntion.resultResponse(False, "",
                                                  MessageCode.OT007.value,
                                                  serializer.errors),
                     status=status.HTTP_400_BAD_REQUEST)
Esempio n. 9
0
 def destroy(self, request, pk=None):
     try:
         queryset = ExhibitionTag.objects.all()
         exhibitionObject = get_object_or_404(queryset, pk=pk)
         data = {"is_active": settings.IS_INACTIVE}
         serializer = ExhibitionTagSerializer(exhibitionObject,
                                              data=data,
                                              partial=True)
         if serializer.is_valid():
             serializer.save(updated=datetime.now())
             return Response(CommonFuntion.resultResponse(
                 True, serializer.data, MessageCode.EXT008.value, ""),
                             status=status.HTTP_200_OK)
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.EXT009.value, serializer.errors),
                         status=status.HTTP_404_BAD_REQUEST)
     except Exception as e:
         return Response(CommonFuntion.resultResponse(
             False, "", MessageCode.EXT003.value, ""),
                         status=status.HTTP_404_NOT_FOUND)
Esempio n. 10
0
 def update(self, request, pk=None):
     request.data['create_user_id'] = request.user.id
     queryset = Exhibition.objects.all()
     event_obj = get_object_or_404(queryset, pk=pk)
     serializer = ExhibitionSerializer(event_obj,
                                       data=request.data,
                                       partial=True)
     if serializer.is_valid():
         serializer.save()
         newtags = request.data.get('newtags')
         if newtags is not None:
             for tag_name in newtags:
                 if not (tag_name == '' or tag_name is None):
                     tag, created = Tag.objects.get_or_create(name=tag_name)
                     ExhibitionTag.objects.create(
                         tag_id=tag.id,
                         exhibition_id=serializer.data['id'],
                         created=datetime.now(),
                         updated=datetime.now())
         removetags = request.data.get('removetags')
         if removetags is not None:
             for tag_id in removetags:
                 exhibitiontags = ExhibitionTag.objects.all().filter(
                     tag_id=tag_id).filter(exhibition_id=pk)
                 if (exhibitiontags is not None):
                     for exhibitiontag in exhibitiontags:
                         exhibitiontag.is_active = 0
                         exhibitiontag.updated = datetime.now()
                         exhibitiontag.save()
         return Response(CommonFuntion.resultResponse(
             True, serializer.data, MessageCode.EX006.value, ""),
                         status=status.HTTP_200_OK)
     return Response(CommonFuntion.resultResponse(False, "",
                                                  MessageCode.EX007.value,
                                                  serializer.errors),
                     status=status.HTTP_400_BAD_REQUEST)
Esempio n. 11
0
 def create(self, request):
     request.data['create_user_id'] = request.user.id
     serializer = ExhibitionSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save(is_active=settings.IS_ACTIVE,
                         created=datetime.now(),
                         updated=datetime.now())
         tags = request.data.get('tags')
         if tags is not None:
             for tag_name in tags:
                 if not (tag_name == '' or tag_name is None):
                     tag, created = Tag.objects.get_or_create(name=tag_name)
                     ExhibitionTag.objects.create(
                         tag_id=tag.id,
                         exhibition_id=serializer.data['id'],
                         created=datetime.now(),
                         updated=datetime.now())
         return Response(CommonFuntion.resultResponse(
             True, serializer.data, MessageCode.EX004.value, ""),
                         status=status.HTTP_201_CREATED)
     return Response(CommonFuntion.resultResponse(False, "",
                                                  MessageCode.EX005.value,
                                                  serializer.errors),
                     status=status.HTTP_400_BAD_REQUEST)
Esempio n. 12
0
    def destroy(self, request, pk=None):
        
        queryset = Event.objects.all()
        event_obj = get_object_or_404(queryset, pk=pk)
        data = {"is_active": settings.IS_INACTIVE}
        serializer = EventSerializer(event_obj, data=data, partial=True)
        if(serializer.is_valid()):
            serializer.save(updated=datetime.now())
            eventContactObject = EventContact.objects.filter(
                is_active=1, event_id=pk)
            if(eventContactObject):
                CommonFuntion.update_active(eventContactObject)
                for item in eventContactObject:
                    eventContactReplyObject = EventContactReply.objects.filter(
                        is_active=1, event_contact_reply=eventContactObject.id)
                    if(eventContactReplyObject):
                        CommonFuntion.update_active(eventContactReplyObject)

            return Response(CommonFuntion.resultResponse(True, serializer.data, MessageCode.EV008.value, ""), status=status.HTTP_200_NO_CONTENT)
        return Response(CommonFuntion.resultResponse(False, "", MessageCode.EV009.value, serializer.errors), status=status.HTTP_400_BAD_REQUEST)
Esempio n. 13
0
 def destroy(self, request, pk=None):
     queryset = Exhibition.objects.all()
     exhibitionObject = get_object_or_404(queryset, pk=pk)
     data = {"is_active": settings.IS_INACTIVE}
     serializer = ExhibitionSerializer(exhibitionObject,
                                       data=data,
                                       partial=True)
     if serializer.is_valid():
         serializer.save(updated=datetime.now())
         exhibitonContactObject = ExhibitionContact.objects.filter(
             is_active=1, exhibition_id=pk)
         if (exhibitonContactObject):
             CommonFuntion.update_active(exhibitonContactObject)
         eventExhibitionObject = EventExhibition.objects.filter(
             is_active=1, exhibition_id=pk)
         if (eventExhibitionObject):
             CommonFuntion.update_active(eventExhibitionObject)
         return Response(CommonFuntion.resultResponse(
             True, serializer.data, MessageCode.EX008.value, ""),
                         status=status.HTTP_200_OK)
     return Response(CommonFuntion.resultResponse(False, "",
                                                  MessageCode.EX009.value,
                                                  serializer.errors),
                     status=status.HTTP_404_BAD_REQUEST)