Ejemplo n.º 1
0
    def save(self, metadata, original, instance, preview=None):
        files = dict(original=original, preview=preview)
        form = DocumentForm(data=metadata, files=files, instance=instance)

        if form.is_valid():
            if self.dry_run:
                self.stdout.write(u'✔ Metadata valid {}'.format(
                                                            metadata['title']))
            else:
                doc = form.save()
                self.stdout.write(u'✔ Uploaded media {}'.format(doc))
        else:
            for field, error in form.errors.items():
                self.skip('{}: {}'.format(field, error.as_text()), metadata)
Ejemplo n.º 2
0
    def save(self, metadata, original, instance, preview=None):
        files = dict(original=original, preview=preview)
        form = DocumentForm(data=metadata, files=files, instance=instance)

        if form.is_valid():
            if self.dry_run:
                self.report.notice('Metadata valid', metadata['title'])
            else:
                doc = form.save()
                self.report.notice('Uploaded media', str(doc))
        else:
            for field, error in form.errors.items():
                self.report.error('{}: {}'.format(field, error.as_text()),
                                  metadata)
Ejemplo n.º 3
0
    def save(self, metadata, original, instance, preview=None):
        files = dict(original=original, preview=preview)
        form = DocumentForm(data=metadata, files=files, instance=instance)

        if form.is_valid():
            if self.dry_run:
                self.report.notice('Metadata valid', metadata['title'])
            else:
                doc = form.save()
                self.report.notice('Uploaded media', str(doc))
        else:
            for field, error in form.errors.items():
                self.report.error('{}: {}'.format(field, error.as_text()),
                                  metadata)
Ejemplo n.º 4
0
def create_document(original_dir, preview_dir=''):
   form = DocumentForm(
       data = {
           'title': "A title",
           'kind': 'video',
           'lang': 'fr',
           'credits':'BSF',
           'summary': 'summary'},
       files = {
           'original': File(open(os.path.join(DATA_PATH, 'a-video.mp4'), 'rb'),
                            name=os.path.join(original_dir, 'a-video.mp4')),
           'preview': File(open(os.path.join(DATA_PATH, 'an-image.jpg'), 'rb'),
                           name=os.path.join(preview_dir, 'an-image.jpg'))
       }
   )
   return form.save()