~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlimages/forms.py

  • Committer: Holger Rapp
  • Date: 2009-03-01 20:47:48 UTC
  • Revision ID: sirver@kallisto.local-20090301204748-h3ouqkp8zhv10ydq
First (working) commit of wlimages app, the app that will handle image uploading and managing. Uploading works now; images can only be uploaded once (with the same filename). Much stil missing. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django import forms
 
2
from models import Image
 
3
 
 
4
import os
 
5
 
 
6
class UploadImageForm(forms.Form):
 
7
    image = forms.ImageField()
 
8
     
 
9
    def clean_image( self ):
 
10
        image = self.cleaned_data["image"]
 
11
 
 
12
        if Image.objects.has_image(image.name.lower()):
 
13
            raise forms.ValidationError, "An Image with this name already exists. Please rename and upload again."
 
14
 
 
15