~ubuntu-branches/debian/squeeze/python-django/squeeze

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb, Chris Lamb, David Spreen, Sandro Tosi
  • Date: 2008-11-19 21:31:00 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081119213100-gp0lqhxl1qxa6dgl
Tags: 1.0.2-1
[ Chris Lamb ]
* New upstream bugfix release. Closes: #505783
* Add myself to Uploaders with ACK from Brett.

[ David Spreen ]
* Remove python-pysqlite2 from Recommends because Python 2.5 includes
  sqlite library used by Django. Closes: 497886

[ Sandro Tosi ]
* debian/control
  - switch Vcs-Browser field to viewsvn

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 = FileSystemStorage(tempfile.gettempdir())
8
 
 
9
 
class Photo(models.Model):
10
 
    title = models.CharField(max_length=30)
11
 
    image = models.FileField(storage=temp_storage, upload_to='tests')
12
 
 
13
 
    # Support code for the tests; this keeps track of how many times save()
14
 
    # gets called on each instance.
15
 
    def __init__(self, *args, **kwargs):
16
 
        super(Photo, self).__init__(*args, **kwargs)
17
 
        self._savecount = 0
18
 
 
19
 
    def save(self, force_insert=False, force_update=False):
20
 
        super(Photo, self).save(force_insert, force_update)
21
 
        self._savecount += 1
22
 
 
23
 
class PhotoForm(ModelForm):
24
 
    class Meta:
25
 
        model = Photo