def save(self, force_insert=False, force_update=False): """Generate the url from the category name""" self.url = slugify( unicode(self.title.replace(u"ł", "l").replace(u"Ł", "L"))) super(NewsCategory, self).save(force_insert, force_update) scaleImage(self.icon.path, width=13)
def save(self, force_insert=False, force_update=False): """Scale logo image""" super(Partners, self).save(force_insert, force_update) # Default width is 200px scaleImage(self.logo.path)
def save(self, force_insert = False, force_update = False): """Generate the url from the category name""" self.url = slugify(unicode(self.title.replace(u"ł", "l").replace(u"Ł", "L"))) super(NewsCategory, self).save(force_insert, force_update) scaleImage(self.icon.path, width = 13)
def save(self, force_insert = False, force_update = False): # For the first time photo upload if not self.id: self.photoMin = u"photoGallery/%s/%s" % (self.parent.directory, str(self.photo).replace(".", "-min.")) if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, self.parent.directory), 0755) super(Photos, self).save(force_insert, force_update) scaleImage(self.photo.path, self.parent.widthPhoto) scaleImage(self.photo.path, self.thumbnailSize, 1) self.photoSize = getFileSize(self.photo.path) if self.selectedModule == 0 or self.selectedModule == 1: chmod(self.photo.path, 0755) chmod(self.photoMin.path, 0755) else: chmod(self.photo.path, 0200) chmod(self.photoMin.path, 0200) if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, self.parent.directory), 0200) else: prevSignlePhoto = "SELECT * from gallery_photos WHERE id = %s" % self.id prevSignlePhoto = Photos.objects.raw(prevSignlePhoto) # If albums are identical if prevSignlePhoto[0].parent == self.parent: if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, prevSignlePhoto[0].parent.directory), 0755) # If photos are different if prevSignlePhoto[0].photo != self.photo: chmod("%s" % prevSignlePhoto[0].photo.path, 0755) chmod("%s" % prevSignlePhoto[0].photoMin.path, 0755) remove("%s" % prevSignlePhoto[0].photo.path) remove("%s" % prevSignlePhoto[0].photoMin.path) super(Photos, self).save(force_insert, force_update) scaleImage(self.photo.path, self.parent.widthPhoto) scaleImage(self.photo.path, self.thumbnailSize, 1) self.photoSize = getFileSize(self.photo.path) self.photoMin = unicode(self.photo).replace(".", "-min.") # If photos are identical elif prevSignlePhoto[0].photo == self.photo: super(Photos, self).save(force_insert, force_update) if self.selectedModule == 0 or self.selectedModule == 1: chmod(self.photo.path, 0755) chmod(self.photoMin.path, 0755) else: chmod(self.photo.path, 0200) chmod(self.photoMin.path, 0200) if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, prevSignlePhoto[0].parent.directory), 0200) # If albums are different elif prevSignlePhoto[0].parent != self.parent: if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, self.parent.directory), 0755) if prevSignlePhoto[0].parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, prevSignlePhoto[0].parent.directory), 0755) # If photos are identical if prevSignlePhoto[0].photo == self.photo: chmod("%s" % prevSignlePhoto[0].photo.path, 0755) chmod("%s" % prevSignlePhoto[0].photoMin.path, 0755) self.photo = unicode(self.photo).replace(prevSignlePhoto[0].parent.directory, self.parent.directory) self.photoMin = unicode(self.photoMin).replace(prevSignlePhoto[0].parent.directory, self.parent.directory) move(prevSignlePhoto[0].photo.path, self.photo.path) move(prevSignlePhoto[0].photoMin.path, self.photoMin.path) # If photos are different elif prevSignlePhoto[0].photo != self.photo: oldPaths = (prevSignlePhoto[0].photo.path, prevSignlePhoto[0].photoMin.path, prevSignlePhoto[0].parent) super(Photos, self).save(force_insert, force_update) scaleImage(self.photo.path, self.parent.widthPhoto) scaleImage(self.photo.path, self.thumbnailSize, 1) chmod(oldPaths[0], 0755) chmod(oldPaths[1], 0755) remove(oldPaths[0]) remove(oldPaths[1]) self.photoSize = getFileSize(self.photo.path) self.photoMin = unicode(self.photo).replace(".", "-min.") if oldPaths[2].selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, oldPaths[2].directory), 0200) if self.selectedModule == 0 or self.selectedModule == 1: chmod(self.photo.path, 0755) chmod(self.photoMin.path, 0755) else: chmod(self.photo.path, 0200) chmod(self.photoMin.path, 0200) if self.parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, self.parent.directory), 0200) if prevSignlePhoto[0].parent.selectedModule == 2: chmod("%s/%s" % (MEDIA_GALLERY, prevSignlePhoto[0].parent.directory), 0200) super(Photos, self).save(force_insert, force_update)
def save(self, force_insert = False, force_update = False): """Scale logo image""" super(Partners, self).save(force_insert, force_update) # Default width is 200px scaleImage(self.logo.path)