コード例 #1
0
ファイル: models.py プロジェクト: woshicainiao/ddtcms
 def handle_uploaded_attachment(self,model_object,attachment_file,attached_by,title=None,summary=None):
     if title is None:
         title = attachment_file.name
     if summary is None:
         summary = attachment_file.name
     object_type = ContentType.objects.get_for_model(model_object)
     object_id   = model_object.id
     
     self.content_type = object_type
     self.object_id    = object_id
     self.title        = title
     self.summary      = summary
     self.attached_by  = attached_by
     self.mimetype     = attachment_file.content_type
     
     file_path =os.path.join(ATTACHMENT_DIR, randomfilename(attachment_file.name))
     self.file.save(file_path, attachment_file,save=False)
     self.save()
コード例 #2
0
ファイル: models.py プロジェクト: feitianyiren/ddtcms
    def handle_uploaded_attachment(self,
                                   model_object,
                                   attachment_file,
                                   attached_by,
                                   title=None,
                                   summary=None):
        if title is None:
            title = attachment_file.name
        if summary is None:
            summary = attachment_file.name
        object_type = ContentType.objects.get_for_model(model_object)
        object_id = model_object.id

        self.content_type = object_type
        self.object_id = object_id
        self.title = title
        self.summary = summary
        self.attached_by = attached_by
        self.mimetype = attachment_file.content_type

        file_path = os.path.join(ATTACHMENT_DIR,
                                 randomfilename(attachment_file.name))
        self.file.save(file_path, attachment_file, save=False)
        self.save()
コード例 #3
0
 def get_storage_path(instance, filename):
     return os.path.join(PHOTOLOGUE_DIR, 'photos', randomfilename(filename))
コード例 #4
0
ファイル: models.py プロジェクト: feitianyiren/ddtcms
 def save_uploaded_file(self, memoryfiledfile):
     file_path = os.path.join(ATTACHMENT_DIR,
                              randomfilename(memoryfiledfile.name))
     self.file.save(file_path, memoryfiledfile)
コード例 #5
0
 def get_storage_path(instance, filename):
     return os.path.join(PHOTOLOGUE_DIR, 'photos', randomfilename(filename))
コード例 #6
0
ファイル: models.py プロジェクト: woshicainiao/ddtcms
 def save_uploaded_file(self,memoryfiledfile):
         file_path =os.path.join(ATTACHMENT_DIR, randomfilename(memoryfiledfile.name))
         self.file.save(file_path, memoryfiledfile)