~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to wlimages/models.py

  • Committer: franku
  • Date: 2018-05-06 08:20:39 UTC
  • mto: This revision was merged to the branch mainline in revision 494.
  • Revision ID: somal@arcor.de-20180506082039-v8n40alffhi2ulct
This is an Attribute error

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    def create(self, **keyw):
25
25
        """Makes sure that no image/revision pair is already in the
26
26
        database."""
27
 
 
28
27
        if 'name' not in keyw or 'revision' not in keyw:
29
28
            raise IntegrityError('needs name and revision as keywords')
30
29
 
33
32
 
34
33
        return super(ImageManager, self).create(**keyw)
35
34
 
36
 
    def create_and_save_image(self, user, image, content_type, object_id):
 
35
    def create_and_save_image(self, user, image, content_type, object_id, ip):
37
36
        # Use Django's get_valid_name() to get a safe filename
38
37
        storage = FileSystemStorage()
39
38
        safe_filename = storage.get_valid_name(image.name)
40
39
        im = self.create(content_type=content_type, object_id=object_id,
41
 
                         user=user, revision=1, name=image.name)
 
40
                         user=user, revision=1, name=image.name, editor_ip=ip)
42
41
        path = '%swlimages/%s' % (MEDIA_ROOT, safe_filename)
43
42
 
44
43
        destination = open(path, 'wb')
70
69
 
71
70
    # User Field
72
71
    user = models.ForeignKey(User)
 
72
    editor_ip = models.GenericIPAddressField(
 
73
        _('IP address'), null=True, blank=True)
73
74
 
74
75
    # Date Fields
75
76
    date_submitted = models.DateTimeField(