本文整理汇总了Python中models.Record.large_cover方法的典型用法代码示例。如果您正苦于以下问题:Python Record.large_cover方法的具体用法?Python Record.large_cover怎么用?Python Record.large_cover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Record
的用法示例。
在下文中一共展示了Record.large_cover方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_acquisition
# 需要导入模块: from models import Record [as 别名]
# 或者: from models.Record import large_cover [as 别名]
def save_acquisition(request):
if request.POST.get('book').isnumeric():
book = Book.objects.get(id=request.POST.get('book'))
new_book = False
else:
book = Book(title=request.POST.get('book'))
new_book = True
book.subtitle = request.POST.get('subtitle')
book.save()
if request.POST.get('isbn'):
isbn = request.POST.get('isbn')
if isbnpy.isValid(isbn):
if isbnpy.isI10(isbn):
isbn = isbnpy.convert(isbn)
try:
record = Record.objects.get(isbn13=isbn)
new_record = False
except Record.DoesNotExist:
record = Record(isbn13=isbn)
new_record = True
else:
if not new_book:
try:
record = Record.objects.get(book=book, edition=request.POST.get('book'))
new_record = False
except Record.DoesNotExist:
record = Record(book=book)
new_record = True
else:
record = Record(book=book)
new_record = True
record.book = book
record.format = request.POST.get('format')
if record.format != 'ebook':
if new_record:
record.quantity = request.POST.get('quantity')
else:
record.quantity += int(request.POST.get('quantity'))
record.excerpt = request.POST.get('excerpt')
record.edition = request.POST.get('edition')
record.notes = request.POST.get('notes')
record.ddc = request.POST.get('ddc')
record.lcc = request.POST.get('lcc')
record.pagination = request.POST.get('pagination')
record.format = request.POST.get('format')
record.type = request.POST.get('type')
if record.format != 'eBook':
record.quantity = request.POST.get('quantity')
record.publication_has_month = False
record.publication_has_day = False
if request.POST.get('year'):
dt = datetime(int(request.POST.get('year')), 1, 1)
if request.POST.get('month'):
record.publication_has_month = True
dt = dt.replace(month=int(request.POST.get('month')))
if request.POST.get('day'):
record.publication_has_day = True
dt = dt.replace(day=int(request.POST.get('day')))
record.date_of_publication = dt
else:
record.date_of_publication = None
if request.FILES.get('small_cover'):
record.small_cover = request.FILES.get('small_cover')
if request.FILES.get('medium_cover'):
record.medium_cover = request.FILES.get('medium_cover')
if request.FILES.get('large_cover'):
record.large_cover = request.FILES.get('large_cover')
if not record.date_added:
record.date_added = datetime.today()
record.save()
if request.FILES.get('ebook'):
ebooks = request.FILES.getlist('ebook')
for ebook in ebooks:
ebook_file = BookFile(record=record, file=ebook)
existing_files = record.ebooks(ebook_file.format)
for existing_file in existing_files:
existing_file.delete()
ebook_file.save()
book.subjects.clear()
for subject in request.POST.getlist('subjects'):
if subject.isnumeric():
book.subjects.add(Subject.objects.get(id=subject))
else:
new_subject = Subject(name=subject)
new_subject.save()
book.subjects.add(new_subject)
record.authors.clear()
for author in request.POST.getlist('authors'):
if author.isnumeric():
record.authors.add(Author.objects.get(id=author))
#.........这里部分代码省略.........