| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # Copyright (C) 2010-2012 Parisson SARL |
|---|
| 3 | |
|---|
| 4 | # This software is a computer program whose purpose is to backup, analyse, |
|---|
| 5 | # transcode and stream any audio content with its metadata over a web frontend. |
|---|
| 6 | |
|---|
| 7 | # This software is governed by the CeCILL license under French law and |
|---|
| 8 | # abiding by the rules of distribution of free software. You can use, |
|---|
| 9 | # modify and/ or redistribute the software under the terms of the CeCILL |
|---|
| 10 | # license as circulated by CEA, CNRS and INRIA at the following URL |
|---|
| 11 | # "http://www.cecill.info". |
|---|
| 12 | |
|---|
| 13 | # As a counterpart to the access to the source code and rights to copy, |
|---|
| 14 | # modify and redistribute granted by the license, users are provided only |
|---|
| 15 | # with a limited warranty and the software's author, the holder of the |
|---|
| 16 | # economic rights, and the successive licensors have only limited |
|---|
| 17 | # liability. |
|---|
| 18 | |
|---|
| 19 | # In this respect, the user's attention is drawn to the risks associated |
|---|
| 20 | # with loading, using, modifying and/or developing or reproducing the |
|---|
| 21 | # software by the user in light of its specific status of free software, |
|---|
| 22 | # that may mean that it is complicated to manipulate, and that also |
|---|
| 23 | # therefore means that it is reserved for developers and experienced |
|---|
| 24 | # professionals having in-depth computer knowledge. Users are therefore |
|---|
| 25 | # encouraged to load and test the software's suitability as regards their |
|---|
| 26 | # requirements in conditions enabling the security of their systems and/or |
|---|
| 27 | # data to be ensured and, more generally, to use and operate it in the |
|---|
| 28 | # same conditions as regards security. |
|---|
| 29 | |
|---|
| 30 | # The fact that you are presently reading this means that you have had |
|---|
| 31 | # knowledge of the CeCILL license and that you accept its terms. |
|---|
| 32 | # |
|---|
| 33 | # Authors: |
|---|
| 34 | # Guillaume Pellerin <yomguy@parisson.com> |
|---|
| 35 | |
|---|
| 36 | import re |
|---|
| 37 | import mimetypes |
|---|
| 38 | from django.contrib.auth.models import User |
|---|
| 39 | from django.utils.translation import ugettext_lazy as _ |
|---|
| 40 | from django.core.exceptions import ValidationError |
|---|
| 41 | from telemeta.models.core import * |
|---|
| 42 | from telemeta.util.unaccent import unaccent_icmp |
|---|
| 43 | from telemeta.models.location import * |
|---|
| 44 | from telemeta.models.system import * |
|---|
| 45 | from telemeta.models.query import * |
|---|
| 46 | from telemeta.models.instrument import * |
|---|
| 47 | from telemeta.models.enum import * |
|---|
| 48 | from telemeta.models.language import * |
|---|
| 49 | from telemeta.models.media import * |
|---|
| 50 | from django.db import models |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | class Format(ModelCore): |
|---|
| 54 | """ Physical format object as proposed by the LAM""" |
|---|
| 55 | |
|---|
| 56 | element_type = 'format' |
|---|
| 57 | |
|---|
| 58 | item = ForeignKey('MediaItem', related_name="format", verbose_name = _("item"), |
|---|
| 59 | blank=True, null=True, on_delete=models.SET_NULL) |
|---|
| 60 | physical_format = WeakForeignKey(PhysicalFormat, related_name="format", |
|---|
| 61 | verbose_name = _("physical format")) |
|---|
| 62 | original_code = CharField(_('original code')) |
|---|
| 63 | original_number = CharField(_('original number')) |
|---|
| 64 | original_status = CharField(_('original status')) |
|---|
| 65 | original_state = TextField(_('technical properties / conservation state')) |
|---|
| 66 | original_comments = TextField(_('comments / notes')) |
|---|
| 67 | original_location = ForeignKey('Location', related_name="format", |
|---|
| 68 | verbose_name = _("original location"), |
|---|
| 69 | blank=True, null=True, on_delete=models.SET_NULL) |
|---|
| 70 | original_channels = WeakForeignKey(NumberOfChannels, related_name="format", |
|---|
| 71 | verbose_name = _("number of channels")) |
|---|
| 72 | original_audio_quality = TextField(_('audio quality')) |
|---|
| 73 | recording_system = CharField(_('recording system')) |
|---|
| 74 | |
|---|
| 75 | # Tapes |
|---|
| 76 | tape_wheel_diameter = WeakForeignKey(TapeWheelDiameter, related_name="format", |
|---|
| 77 | verbose_name = _("tape wheel diameter (cm)")) |
|---|
| 78 | tape_thickness = CharField(_('tape thickness (um)')) |
|---|
| 79 | tape_speed = WeakForeignKey(TapeSpeed, related_name="format", |
|---|
| 80 | verbose_name = _("tape speed (m/s)")) |
|---|
| 81 | tape_vendor = WeakForeignKey(TapeVendor, related_name="format", |
|---|
| 82 | verbose_name = _("tape vendor")) |
|---|
| 83 | tape_reference = CharField(_('tape reference')) |
|---|
| 84 | sticker_presence = BooleanField(_('sticker presence')) |
|---|
| 85 | |
|---|
| 86 | class Meta(MetaCore): |
|---|
| 87 | db_table = 'media_formats' |
|---|
| 88 | verbose_name = _('format') |
|---|
| 89 | |
|---|
| 90 | def __unicode__(self): |
|---|
| 91 | if self.physical_format: |
|---|
| 92 | return ' - '.join([self.physical_format.value, self.original_code, |
|---|
| 93 | self.item.public_id]) |
|---|
| 94 | else: |
|---|
| 95 | return 'Unknown' |
|---|
| 96 | |
|---|
| 97 | @property |
|---|
| 98 | def public_id(self): |
|---|
| 99 | return self.original_code |
|---|