Example #1
0
 def save(self, commit=True):
     instance = self.cleaned_data['organization']
     image = Image.open(self.cleaned_data['image'])
     box = (self.cleaned_data['x'], self.cleaned_data['y'],
            self.cleaned_data['x2'], self.cleaned_data['y2'], )
     instance.image = handle_tmp_image(image.crop(box))
     if commit:
         instance.save()
     return instance
Example #2
0
 def save(self, commit=True):
     instance = self.cleaned_data['organization']
     image = Image.open(self.cleaned_data['image'])
     box = (self.cleaned_data['x'], self.cleaned_data['y'],
            self.cleaned_data['x2'], self.cleaned_data['y2'], )
     instance.image = handle_tmp_image(image.crop(box))
     if commit:
         instance.save()
     return instance
Example #3
0
 def form_valid(self, form):
     box = (form.cleaned_data['x'], form.cleaned_data['y'],
            form.cleaned_data['x2'], form.cleaned_data['y2'], )
     obj = self.get_object()
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     obj.image = handle_tmp_image(image)
     obj.save()
     return redirect(reverse(
         'locations:project_details',
         kwargs={'location_slug': obj.location.slug,
                 'slug': obj.slug, }))
Example #4
0
    def is_valid(self):
        valid = super(BackgroundUploadForm, self).is_valid()
        if not valid:
            return valid

        image = self.cleaned_data['image']
        box = (
            self.cleaned_data['x'],
            self.cleaned_data['y'],
            self.cleaned_data['x2'],
            self.cleaned_data['y2'], )
        image = Image.open(image)
        image = image.crop(box)

        if self.instance is not None:
            self.instance.image = handle_tmp_image(image)
            self.instance.save()

        self.cleaned_data['image'] = handle_tmp_image(image)

        return True
Example #5
0
 def form_valid(self, form):
     from gallery.image import handle_tmp_image
     box = (
         form.cleaned_data['x'],
         form.cleaned_data['y'],
         form.cleaned_data['x2'],
         form.cleaned_data['y2'],
     )
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     profile = UserProfile.objects.get(user=self.request.user)
     profile.image = handle_tmp_image(image)
     profile.save()
     return redirect(self.request.user.profile.get_absolute_url())
Example #6
0
 def form_valid(self, form):
     from gallery.image import handle_tmp_image
     box = (
         form.cleaned_data['x'],
         form.cleaned_data['y'],
         form.cleaned_data['x2'],
         form.cleaned_data['y2'],
     )
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     profile = UserProfile.objects.get(user=self.request.user)
     profile.image = handle_tmp_image(image)
     profile.save()
     return redirect(self.request.user.profile.get_absolute_url())
Example #7
0
 def form_valid(self, form):
     from PIL import Image
     from gallery.image import handle_tmp_image
     box = (
         form.cleaned_data['x'],
         form.cleaned_data['y'],
         form.cleaned_data['x2'],
         form.cleaned_data['y2'],
     )
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     location = Location.objects.get(pk=self.kwargs.get('pk', None))
     location.image = handle_tmp_image(image)
     location.save()
     return redirect(reverse('locations:details',
                      kwargs={'slug': location.slug}))
Example #8
0
 def form_valid(self, form):
     from PIL import Image
     from gallery.image import handle_tmp_image
     box = (
         form.cleaned_data['x'],
         form.cleaned_data['y'],
         form.cleaned_data['x2'],
         form.cleaned_data['y2'],
     )
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     location = Location.objects.get(pk=self.kwargs.get('pk', None))
     location.image = handle_tmp_image(image)
     location.save()
     return redirect(reverse('locations:details',
                      kwargs={'slug': location.slug}))
Example #9
0
 def form_valid(self, form):
     box = (
         form.cleaned_data['x'],
         form.cleaned_data['y'],
         form.cleaned_data['x2'],
         form.cleaned_data['y2'],
     )
     obj = self.get_object()
     image = Image.open(form.cleaned_data['image'])
     image = image.crop(box)
     obj.image = handle_tmp_image(image)
     obj.save()
     return redirect(
         reverse('locations:project_details',
                 kwargs={
                     'location_slug': obj.location.slug,
                     'slug': obj.slug,
                 }))