def setUpTestData(cls): cls.user = User.objects.create_user("foo_user", password="******", last_name="foo lastname", first_name="foo firstname") object = TestObject.objects.create(name="foo object") cls.filetype = get_filetype_model().objects.create(type="foo filetype") get_attachment_model().objects.create(content_object=object, filetype=cls.filetype, attachment_file="foo_file.txt", creator=cls.user, author="foo author", title="foo title", legend="foo legend", starred=True) cls.pk = object.pk
def attachmentPostData(self): filetype = get_filetype_model().objects.create() uploaded = SimpleUploadedFile('face.jpg', '*' * 128, content_type='image/jpeg') data = { 'filetype': filetype.pk, 'title': 'A title', 'legend': 'A legend', 'attachment_file': uploaded, 'attachment_video': '', 'next': self.object.get_detail_url() } return data
def attachmentPostData(self): filetype = get_filetype_model().objects.create() uploaded = SimpleUploadedFile('face.jpg', b'*' * 128, content_type='image/jpeg') data = { 'filetype': filetype.pk, 'title': 'A title', 'legend': 'A legend', 'attachment_file': uploaded, 'attachment_video': '', 'next': self.object.get_detail_url() } return data
def createAttachment(self, obj): uploaded = SimpleUploadedFile('file.odt', b'*' * 128, content_type='application/vnd.oasis.opendocument.text') kwargs = { 'content_type': ContentType.objects.get_for_model(obj), 'object_id': obj.pk, 'filetype': get_filetype_model().objects.create(), 'creator': self.user, 'title': "Attachment title", 'legend': "Attachment legend", 'attachment_file': uploaded } return get_attachment_model().objects.create(**kwargs)
def setUpTestData(cls): cls.user = User.objects.create_user("foo_user", password="******", last_name="foo lastname", first_name="foo firstname") object = TestObject.objects.create(name="foo object") cls.filetype = get_filetype_model().objects.create(type="foo filetype") get_attachment_model().objects.create(content_object=object, filetype=cls.filetype, attachment_file="foo_file.txt", creator=cls.user, author="foo author", title="foo title", legend="foo legend", starred=True) cls.pk = object.pk
from django.contrib import admin from paperclip import settings from paperclip.admin import AttachmentInlines from .models import TestObject admin.site.register(settings.get_filetype_model()) admin.site.register(settings.get_attachment_model()) @admin.register(TestObject) class TestObjectAdmin(admin.ModelAdmin): inlines = [AttachmentInlines]
from django.contrib import admin from paperclip import settings from paperclip.admin import AttachmentInlines from .models import TestObject admin.site.register(settings.get_filetype_model()) admin.site.register(settings.get_attachment_model()) @admin.register(TestObject) class TestObjectAdmin(admin.ModelAdmin): inlines = [AttachmentInlines]