def clean_content(self):
        t = ExtFileField(ext_whitelist=FILES_WHITELIST)
        if self.prefix:
            field_name = "%s-content" % self.prefix
        else:
            field_name = "content"

        if not self.files.has_key(field_name):
            return
        file_field = self.files[field_name]
        t.clean(file_field)
        if file_field._size > settings.MAX_UPLOAD_SIZE:
            raise forms.ValidationError(
                _("Please keep filesize under %s. Current filesize is %s")
                % (filesizeformat(settings.MAX_UPLOAD_SIZE), filesizeformat(file_field._size))
            )
        fname = file_field.name
        extn = fname[(fname.rfind(".") + 1) :]
        print extn
        fname = "%s/files/%s-%d-%d.%s" % (
            settings.MEDIA_ROOT,
            util.camelize(self.question.event.name),
            self.instance.answered_by.id,
            self.instance.question.id,
            extn,
        )
        file_field.name = fname

        if os.path.isfile(fname):
            os.remove(fname)

        # Django takes care of saving the file
        return file_field
 def save(self, *args, **kwargs):
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) )
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) + "/files")
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) + "/submissions")
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) + "/images")
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) + "/images/eventlogos")
     os.system("mkdir " + MEDIA_ROOT + EVENTS_PATH + camelize(self.name) + "/images/sponslogos")
     return super(Event, self).save(*args, **kwargs) # Call the "real" save() method.
 def get_url(self):
     if self.event is not None:
         return self.event.url
     return SITE_URL + 'events/' + camelize(self.text) + '/'
def get_sponslogo_path(instance, filename):
	return EVENTS_PATH + camelize(instance.name) + '/images/sponslogos/' + filename