{5} Assigned, Active Tickets by Owner (Full Description) (1 matches)

List tickets assigned, group by ticket owner. This report demonstrates the use of full-row display.

bryan

Ticket Summary Component Milestone Type Created
Description
#5 Should PhotoField automatically rename uploaded files? PhotoField defect 09/06/06

I think it's not a great idea to change image file name. Search engines looks onto them to index.

I've changed it a little (3 lines marked with comments):

    def save_file(self, new_data, new_object, original_object, change, rel):
        field_names = self.get_manipulator_field_names('')
        upload_field_name = field_names[0]
        #filename = '%s-%s.jpg' % (self.parent_pk, self.get_attname())      #235 - fix names
        # If there is no DeleteCheckbox or the DeleteCheckbox was not checked
        if len(field_names) < 3 or not new_data.get(field_names[2], False):
            if new_data.get(upload_field_name, False):
                if rel:
                    #new_data[upload_field_name][0]["filename"] = filename  #235 - fix names
                    filename = new_data[upload_field_name][0]["filename"]
                    new_data[upload_field_name][0]["content"] = PhotoField.resize(new_data[upload_field_name][0]["content"], self.width, self.height, self.mode, self.quality)
                else:
                    #new_data[upload_field_name]["filename"] = filename     #235- fix names
                    filename = new_data[upload_field_name]["filename"]
                    new_data[upload_field_name]["content"] = PhotoField.resize(new_data[upload_field_name]["content"], self.width, self.height, self.mode, self.quality)
                # If file exists, delete it
                filepath = os.path.join(settings.MEDIA_ROOT, self.upload_to, filename)
                if os.path.exists(filepath):
                    os.remove(filepath)
        super(PhotoField, self).save_file(new_data, new_object, original_object, change, rel)

Note: See TracReports for help on using and creating reports.