def save(self, *args, **kwargs): # If this is the current contact form, update checklist if str(self.pk) == get_setting('site', 'global', 'contact_form'): checklist_update('update-contact') if not self.group: self.group_id = get_default_group() super(Form, self).save(*args, **kwargs)
def save(self, *args, **kwargs): initial_save = not self.id if not self.id: self.guid = str(uuid.uuid4()) if not self.group: self.group_id = get_default_group() super(Image, self).save(*args, **kwargs) # clear the cache #caching.instance_cache_clear(self, self.pk) #caching.cache_clear(PHOTOS_KEYWORDS_CACHE, key=self.pk) # re-add instance to the cache #caching.instance_cache_add(self, self.pk) if not self.is_public_photo() or not self.is_public_photoset(): if hasattr( settings, 'USE_S3_STORAGE') and settings.USE_S3_STORAGE and hasattr( self.image, 'file'): set_s3_file_permission(self.image.file, public=False) cache_set = cache.get("photos_cache_set.%s" % self.pk) if cache_set is not None: # TODO remove cached images cache.delete_many(cache.get("photos_cache_set.%s" % self.pk)) cache.delete("photos_cache_set.%s" % self.pk) if initial_save: try: exif_exists = self.get_exif_data() if exif_exists: self.save() except AttributeError: pass
def populate_default_group(apps, schema_editor): from tendenci.apps.user_groups.utils import get_default_group try: group_id = get_default_group() File = apps.get_model("files", "File") File.objects.filter(group=None).update(group_id=group_id) except: pass
def save(self, *args, **kwargs): self.guid = self.guid or str(uuid.uuid4()) if not self.group: self.group_id = get_default_group() super(PhotoSet, self).save() if not self.is_public(): for photo in Image.objects.filter(photoset=self.pk): set_s3_file_permission(photo.image.file, public=False) cache_set = cache.get("photos_cache_set.%s" % photo.pk) if cache_set is not None: # TODO remove cached images cache.delete_many(cache.get("photos_cache_set.%s" % photo.pk)) cache.delete("photos_cache_set.%s" % photo.pk)
def save(self, *args, **kwargs): created = False if not self.id: self.guid = str(uuid.uuid4()) created = True self.f_type = self.type() if not self.group: self.group_id = get_default_group() super(File, self).save(*args, **kwargs) if self.is_public_file(): set_s3_file_permission(self.file, public=True) else: set_s3_file_permission(self.file, public=False) cache_set = cache.get("files_cache_set.%s" % self.pk) if cache_set is not None: # TODO remove cached images cache.delete_many(cache.get("files_cache_set.%s" % self.pk)) cache.delete("files_cache_set.%s" % self.pk) # send notification to administrator(s) and module recipient(s) if created: recipients = get_notice_recipients('module', 'files', 'filerecipients') site_display_name = get_setting('site', 'global', 'sitedisplayname') site_url = get_setting('site', 'global', 'siteurl') if recipients and notification: notification_params = { 'object': self, 'SITE_GLOBAL_SITEDISPLAYNAME': site_display_name, 'SITE_GLOBAL_SITEURL': site_url, } if self.owner: notification_params['author'] = self.owner.get_full_name( ) or self.owner notification.send_emails(recipients, 'file_added', notification_params)
def save(self, *args, **kwargs): created = False if not self.id: self.guid = str(uuid.uuid4()) created = True self.f_type = self.type() if not self.group: self.group_id = get_default_group() super(File, self).save(*args, **kwargs) if self.is_public_file(): set_s3_file_permission(self.file, public=True) else: set_s3_file_permission(self.file, public=False) cache_set = cache.get("files_cache_set.%s" % self.pk) if cache_set is not None: # TODO remove cached images cache.delete_many(cache.get("files_cache_set.%s" % self.pk)) cache.delete("files_cache_set.%s" % self.pk) # send notification to administrator(s) and module recipient(s) if created: recipients = get_notice_recipients('module', 'files', 'filerecipients') site_display_name = get_setting('site', 'global', 'sitedisplayname') site_url = get_setting('site', 'global', 'siteurl') if recipients and notification: notification_params = { 'object': self, 'SITE_GLOBAL_SITEDISPLAYNAME': site_display_name, 'SITE_GLOBAL_SITEURL': site_url, } if self.owner: notification_params['author'] = self.owner.get_full_name() or self.owner notification.send_emails(recipients, 'file_added', notification_params)
def save(self, *args, **kwargs): if not self.group: self.group_id = get_default_group() super(Page, self).save(*args, **kwargs)