Beispiel #1
0
 def post_save(self, obj, created=False):
     if self.custom_field_form:
         serializer = FormSchemaSerializer(
             data={'field_groups': self.custom_field_form})
         if serializer.is_valid():
             form_object = serializer.save(force_insert=True)
             obj.custom_field_form = form_object
             obj.save()
Beispiel #2
0
    def post_save(self, obj, created=False):
        if not created:
            return
        f = self.request.FILES.get('file', None)
        save_image(f, obj, 'image', 'name', 'location/')

        if self.custom_field_form:
            serializer = FormSchemaSerializer(
                data=self.custom_field_form)
            if serializer.is_valid():
                form_object = serializer.save(force_insert=True)
                obj.custom_field_form = form_object
                obj.save()
Beispiel #3
0
    def post_save(self, obj, created=False):
        f = self.request.FILES.get('file', None)
        save_thumb(f, obj, 'icon', 'name', 'location_type/')

        if self.custom_field_form:
            serializer = FormSchemaSerializer(
                data=self.custom_field_form, many=False)
            if serializer.is_valid():
                form_object = serializer.save(force_insert=True)
                obj.custom_field_form = form_object
                obj.save()
        if self.taxonomies:
            obj.taxonomies = self.taxonomies
            obj.save()
Beispiel #4
0
 def post_save(self, obj, created=False):
     f = self.request.FILES.get('file', None)
     save_image(f, obj, 'image', 'name', 'location/')
     if self.custom_field_form:
         serializer = FormSchemaSerializer(
             data=self.custom_field_form)
         if serializer.is_valid():
             form_object = serializer.save(force_insert=True)
             obj.custom_field_form = form_object
             obj.save()
     if self.tags:
         for tag in self.tags:
             print tag
             Categories.objects(id=tag['id']).update_one(push__tagged=obj)
Beispiel #5
0
    def post_save(self, obj, created=False):
        # MongoEngine ReferenceField cannot accept None Type. So have to
        # do the trick here to remove the 'inherit'.
        if 'inherit' not in self.request.DATA:
            del obj.inherit
            obj.save()

        if self.custom_field_form:
            serializer = FormSchemaSerializer(
                data={'field_groups': self.custom_field_form})
            if serializer.is_valid():
                form_object = serializer.save(force_insert=True)
                obj.custom_field_form = form_object
                obj.save()
Beispiel #6
0
    def post_save(self, obj, created=False):
        f = self.request.FILES.get('file', None)
        save_image(f, obj, 'image', 'full_name', 'user/')
        if 'password' in self.request.DATA and self.request.DATA[
                'password'] != '':
            obj.set_password(self.request.DATA['password'])
            obj.save()

        # i dont know, how to make serializers to save nested entities in mongoengine, so do it manually
        if self.custom_field_form:
            serializer = FormSchemaSerializer(
                data={'field_groups': self.custom_field_form})
            if serializer.is_valid():
                form_object = serializer.save(force_insert=True)
                obj.custom_field_form = form_object

        if self.primary_user_type:
            obj.primary_user_type = self._get_primary_type()

        obj.save()
Beispiel #7
0
    def post_save(self, obj, created=False):
        # MongoEngine ReferenceField cannot accept None Type. So have to
        # do the trick here to remove the 'organization'.
        if 'organization' not in self.request.DATA:
            del obj.organization
            obj.save()

        if self.custom_field_form:
            serializer = FormSchemaSerializer(
                data={'field_groups': self.custom_field_form})
            if serializer.is_valid():
                form_object = serializer.save(force_insert=True)
                obj.custom_field_form = form_object
                obj.save()

        if created:
            obj.set_password(self.request.DATA['password'])
            obj.save()

            send_email_confirmation(site, obj.id)
            f = self.request.FILES.get('file', None)
            save_image(f, obj, 'image', 'full_name', 'user/')