~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to tests/regressiontests/bug639/models.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import tempfile
 
2
 
 
3
from django.db import models
 
4
from django.core.files.storage import FileSystemStorage
 
5
from django.forms import ModelForm
 
6
 
 
7
temp_storage_dir = tempfile.mkdtemp()
 
8
temp_storage = FileSystemStorage(temp_storage_dir)
 
9
 
 
10
class Photo(models.Model):
 
11
    title = models.CharField(max_length=30)
 
12
    image = models.FileField(storage=temp_storage, upload_to='tests')
 
13
 
 
14
    # Support code for the tests; this keeps track of how many times save()
 
15
    # gets called on each instance.
 
16
    def __init__(self, *args, **kwargs):
 
17
        super(Photo, self).__init__(*args, **kwargs)
 
18
        self._savecount = 0
 
19
 
 
20
    def save(self, force_insert=False, force_update=False):
 
21
        super(Photo, self).save(force_insert, force_update)
 
22
        self._savecount += 1
 
23
 
 
24
class PhotoForm(ModelForm):
 
25
    class Meta:
 
26
        model = Photo