Exemplo n.º 1
0
class WorkForm(forms.Form):
    paper_word = forms.FileField(required = False, 
                                 validators = [validators.FileExtensionValidator(['doc', 'docx'], message = "文件必须为doc/docx格式")])
            
    paper_pdf = forms.FileField(required = False, 
                                validators = [validators.FileExtensionValidator(['pdf'], message = "文件必须为pdf格式")])
    paper_cc = forms.FileField(required = False, 
                               validators = [validators.FileExtensionValidator(['pdf'], message = "文件必须为pdf格式")])
Exemplo n.º 2
0
class UploadFoldChangesFormGSEA(forms.Form):
    """Upload run DGE analysis or submit fold changes form class."""
    run_analysis_results_gsea = forms.BooleanField(
        label='Run differential gene expression analysis',
        required=False,
    )

    read_counts_file_gsea = forms.FileField(
        label='Upload read counts',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> If you would like to perform differential gene "
                  "expression analysis and are running GSEA, please ensure the counts matrix corresponds "
                  "to the class labels file above. The following file formats are supported: *.csv *.tsv or *.txt."
    )

    class_file_fc_gsea = forms.FileField(
        label='Upload class labels',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> If you are running GSEA and have already uploaded a class labels file, "
                  "you can skip this step. If you are running GSEA preranked, Please ensure you have also uploaded a"
                  " read counts matrix. The following file formats are supported: *.csv, *.tsv or *.txt."
    )

    significance_value_run_gsea = forms.FloatField(
        label='Significance threshold (adjusted <i>p</i>-value)',
        required=False,
        help_text="Significance threshold to filter differentially expressed genes. <strong>Default:</strong> 0.05"
    )

    upload_fold_changes_gsea = forms.BooleanField(
        label='Upload results of differential gene expression analysis',
        required=False,
    )

    fold_changes_file_gsea = forms.FileField(
        label='Upload fold changes',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> If you are uploading GSEA results, please ensure the "
                  "fold changes correspond to the same samples from your GSEA run. The following file formats are "
                  "supported: *.csv *.tsv or *.txt."
    )

    significance_value_upload_gsea = forms.FloatField(
        label='Significance threshold (adjusted <i>p</i>-value)',
        required=False,
        help_text="Significance threshold to filter differentially expressed genes. <strong>Default:</strong> 0.05"
    )
Exemplo n.º 3
0
class UploadFoldChangesForm(forms.Form):
    """Upload run DGE analysis or submit fold changes form class."""
    run_analysis = forms.BooleanField(
        label='Run differential gene expression analysis',
        required=False,
    )

    read_counts_file = forms.FileField(
        label='Upload read counts',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> this field is optional. If you would like to perform differential gene "
                  "expression analysis, please ensure a class labels file is uploaded below with samples in the same "
                  "order as the read counts file. The following file formats are supported: *.csv *.tsv or *.txt."
    )

    class_file = forms.FileField(
        label='Upload class labels',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> this field is optional. Please ensure you have also uploaded a read counts"
                  " matrix. The following file formats are supported: *.csv *.tsv or *.txt."
    )

    significance_value_run = forms.FloatField(
        label='Significance threshold (adjusted <i>p</i>-value)',
        required=False,
        help_text="Significance threshold to filter differentially expressed genes. <strong>Default:</strong> 0.05"
    )

    upload_fold_changes = forms.BooleanField(
        label='Upload differential gene expression analysis results',
        required=False,
    )

    fold_changes_file = forms.FileField(
        label='Upload fold changes',
        required=False,
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Note:</strong> this field is optional. If you are uploading GSEA results, please ensure the "
                  "fold changes correspond to the same samples from your GSEA run. The following file formats are "
                  "supported: *.csv *.tsv or *.txt."
    )

    significance_value_upload = forms.FloatField(
        label='Significance threshold (adjusted <i>p</i>-value)',
        required=False,
        help_text="Significance threshold to filter differentially expressed genes. <strong>Default:</strong> 0.05"
    )
Exemplo n.º 4
0
class BookAuthor(models.Model):
    '''
    E-Management `BookAuthor` Model

    fields = ['id', 'first_name', 'middle_name', 'last_name', 'date_of_birth', 'died', 'aboutAuthor', 'genre']
    '''
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    first_name = models.CharField(verbose_name="First Name", max_length=100)
    middle_name = models.CharField(verbose_name="Middle Name", max_length=100)
    last_name = models.CharField(verbose_name="Last Name", max_length=100)
    date_of_birth = models.DateField(null=True)
    died = models.DateField(verbose_name='Died', null=True, blank=True)
    aboutAuthor = models.TextField(max_length=250)
    genre = models.ManyToManyField(
        Genre, verbose_name="Genre", help_text='Hold down “Control”, or “Command” on a Mac, to select more than one.')
    profile = models.FileField(
        upload_to=utils.pic_upload, verbose_name="Author Profile",
        default="user.jpg", blank=True,
        validators=[validators.FileExtensionValidator(
                allowed_extensions=validators.get_available_image_extensions(),
                message="Select valid Cover Image."), utils.profile_size
        ],
    )

    class Meta:
        ordering = ['date_of_birth']
        unique_together = ('first_name', 'last_name',)

    def __str__(self):
        return f"{self.first_name} {self.last_name}"
Exemplo n.º 5
0
class TeacherImport(models.Model):
    file = models.FileField(upload_to='excel',
                            validators=[
                                validators.FileExtensionValidator(
                                    ['xls', 'xlsx'],
                                    message='必须为excel文件,后缀名为xls,xlsx!')
                            ])
Exemplo n.º 6
0
class Post(models.Model):
    url = models.URLField(max_length=200, default="", blank=True)
    title = models.CharField(max_length=200, blank=True)
    cover = models.FileField(upload_to="pdf/",
                             validators=[
                                 validators.FileExtensionValidator(
                                     ['pdf'], message='file must be pdf')
                             ],
                             blank=False)
    # cover = models.ImageField(upload_to="images/", default=None, blank=True)
    created = models.DateTimeField(auto_now_add=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE, default=None)

    def save(self, *args, **kwargs):
        if self.url and not self.cover:
            response = requests.get(self.url)
            if response.status_code == 200:
                self.cover.save(os.path.basename(self.url),
                                ContentFile(response.content),
                                save=True)
            else:
                pass
        if self.title == '':
            self.title = self.cover.name
        super().save(*args, **kwargs)

    def __str__(self):
        return self.title
Exemplo n.º 7
0
class Bb(models.Model):
    title = models.CharField(max_length=50, verbose_name='Товар')
    content = models.TextField(null=True, blank=True, verbose_name='Описание')
    price = models.FloatField(null=True, blank=True, verbose_name='Цена')
    img = models.ImageField(
        verbose_name='Изображение',
        validators=[
            validators.FileExtensionValidator(allowed_extensions=('jpg', 'png',
                                                                  'gif'))
        ],
        error_messages={
            'invalid_extension': 'Этот формат файла - не поддерживается'
        },
        upload_to='')
    published = models.DateTimeField(auto_now_add=True,
                                     db_index=True,
                                     verbose_name='Опубликовано')
    rubric = models.ForeignKey(Rubric,
                               on_delete=models.PROTECT,
                               verbose_name='Рубрика',
                               default='Недвижимость')

    def get_absolute_url(self):
        return '/detail/%s/' % self.pk

    class Meta:
        verbose_name_plural = 'Объявления'
        verbose_name = 'Объявление'
        ordering = ['-published']
Exemplo n.º 8
0
class app_user_data_form_api(forms.Form):
    username = forms.CharField(max_length=10, min_length=6,
                               error_messages={'required': '不能为空', "max_length": '用户名长度不大于10',
                                               'min_length': '用户名长度不小于6'})
    phoneNumber = forms.CharField(max_length=11, error_messages={'required': '不能为空', "max_length": '请输入有效的手机号码',
                                                                 "invalid": '请输入有效的手机号码',
                                                                 'min_length': '请输入有效的手机号码'},
                                  validators=(validators.RegexValidator(regex='[\d]{11}'),))
    useremail = forms.EmailField(error_messages={'required': '不能为空', 'invalid': '请输入有效的电子邮件地址'})
    userPassword = forms.CharField(max_length=10, min_length=6,
                                   error_messages={'required': '不能为空', "max_length": '密码长度不大于10',
                                                   "min_length": '密码长度小于6'})

    idiograph = forms.CharField(required=False)

    personal_icon_image = forms.ImageField(required=False, validators=[
        validators.FileExtensionValidator(allowed_extensions=['jpg', 'png']), ])

    def clean_username(self):
        username = self.cleaned_data.get('username')
        if UserDataModels.objects.filter(username=username).exists():
            raise forms.ValidationError(code='UserRepeat', message='用户已存在')
        return username

    def clean_phoneNumber(self):
        phoneNumber = self.cleaned_data.get('phoneNumber')
        if UserDataModels.objects.filter(phoneNumber=phoneNumber).exists():
            raise forms.ValidationError(code='PhonenumberRepeat', message='该手机号码不可用')
        return phoneNumber

    def clean_useremail(self):
        useremail = self.cleaned_data.get('useremail')
        if UserDataModels.objects.filter(useremail=useremail).exists():
            raise forms.ValidationError(code='400', message='该邮箱已存在')
        return useremail
Exemplo n.º 9
0
class GameRegisterForm(forms.Form):
    name = forms.CharField(
        label="游戏名",
        max_length=20,
        min_length=3,
        widget=forms.TextInput(attrs={"placeholder": "请输入游戏名"}))
    price = forms.FloatField(label="价格", min_value=0)
    avatar = forms.ImageField(label="封面")
    type = forms.ModelChoiceField(label="游戏类型",
                                  queryset=GameType.objects.all())
    files = forms.FileField(
        validators=[validators.FileExtensionValidator(['swf'])])
    introduction = forms.CharField(widget=forms.Textarea(
        attrs={
            'width': "40%",
            'cols': "80",
            'rows': "20",
        }))

    # 在clean验证的时候其实可以根据每一个不同的字段进行验证的
    def clean_name(self):
        name = self.cleaned_data["name"]
        if Game.objects.filter(name=name).exists():
            raise forms.ValidationError("游戏名已存在")
        return name
Exemplo n.º 10
0
class UploadRCPForm(forms.Form):
    submit_label = 'Upload payments'
    file = forms.FileField(
        validators=[validators.FileExtensionValidator(['csv'])],
        widget=forms.FileInput(attrs={'accept': '.csv'}),
        help_text='A payments .csv file from WPM',
    )
Exemplo n.º 11
0
class UploadImageForm(forms.Form):
    file = forms.ImageField(
        validators=[
            validators.FileExtensionValidator(allowed_extensions=('gif', 'jpg',
                                                                  'png'))
        ],
        error_messages={'invalid extension': 'Этот формат не поддерживается'})
Exemplo n.º 12
0
class UploadFileForm(forms.Form):
    # 文件上传
    instrument = [
        ("AB", "AB"),
        ("WATERS", "WATERS"),
        ("Agilent", "Agilent"),
        ("daojin", "岛津"),
    ]

    item = [
        (None, ""),
        ("PMNs", "血浆MNs"),
        ("UMNs", "尿液MNs"),
        ("Ald", "血浆醛固酮"),
        ("UAld", "尿液醛固酮"),
        ("VD", "25OH维生素D"),
    ]
    item_name = forms.ChoiceField(label='项目名称', choices=item)
    instrument_type = forms.ChoiceField(label="仪器厂家", choices=instrument)
    instrument_num = forms.CharField(label='仪器编号',
                                     max_length=4,
                                     validators=[
                                         validators.RegexValidator(
                                             r"[A-Za-z]{2}(\d){2}",
                                             "仪器编号格式错误,请确认!")
                                     ])
    file = forms.FileField(
        label='原始数据',
        validators=[
            validators.FileExtensionValidator(["txt", "csv", "xml", "docx"],
                                              "文件类型错误,请确认!")
        ])
Exemplo n.º 13
0
class OpinionForm(forms.ModelForm):
    date = forms.TextInput(attrs={'class': 'span2', 'id': 'dp1'})
    contract = forms.ModelChoiceField(queryset=Contracts.objects.none())
    author = forms.TextInput()
    opinion_text = forms.Textarea(attrs={'rows': 3})
    opinion_file = forms.FileField(
        label='Файл',
        validators=[validators.FileExtensionValidator(
            allowed_extensions=('jpg', 'png', 'pdf', 'doc', 'docx', 'odt'))],
        error_messages={'invalid_extension': 'Этот формат '
                                             + 'файлов не поддерживается'},
        required=False)

    class Meta:
        model = Opinion
        fields = ('date', 'contract', 'author', 'opinion_text', 'opinion_file')
        # required = ('date', 'author', 'opinion_text') # не сработало

    def __init__(self, *args, **kwargs):
        if 'contracts' in kwargs:
            qs = kwargs.pop('contracts')
        else:
            qs = None

        super(OpinionForm, self).__init__(*args, **kwargs)

        try:
            self.fields['contract'].queryset = qs
            self.fields['contract'].required = False
        except AttributeError:
            pass
Exemplo n.º 14
0
class ReferenceDataRecordUploadForm(forms.Form):
    file = forms.FileField(
        label='CSV file',
        required=True,
        validators=[validators.FileExtensionValidator(allowed_extensions=['csv'])],
    )

    def __init__(self, *args, **kwargs):
        self.reference_dataset = kwargs.pop('reference_dataset')
        super().__init__(*args, **kwargs)

    def clean_file(self):
        reader = csv.DictReader(chunk.decode() for chunk in self.cleaned_data['file'])
        csv_fields = [x.lower() for x in reader.fieldnames]
        for field in [
            field.name.lower()
            if field.data_type != field.DATA_TYPE_FOREIGN_KEY
            else field.relationship_name_for_record_forms.lower()
            for _, field in self.reference_dataset.editable_fields.items()
        ]:
            if field not in csv_fields:
                raise forms.ValidationError(
                    'Please ensure the uploaded csv file headers include '
                    'all the target reference dataset columns'
                )
        return self.cleaned_data['file']
Exemplo n.º 15
0
class UserModel(AbstractBaseUser, PermissionsMixin):
    name = models.CharField(
        max_length=10,
        validators=[userNameMaxLengthValidator, userNameMinLengthValidator],
        null=False,
        unique=True)
    email = models.EmailField(null=True, unique=True)
    icon = models.FileField(upload_to='images', default='default.jpg')
    telephone = models.CharField(max_length=11,
                                 validators=[telephoneValidator],
                                 unique=True)
    date_join = models.DateTimeField(
        auto_now_add=True,
        validators=[
            validators.FileExtensionValidator(
                allowed_extensions=['jpg', 'png', 'jpeg'], message='不支持的图片格式')
        ])
    # is_superuser = models.BooleanField()
    USERNAME_FIELD = 'name'
    REQUIRED_FIELDS = []

    objects = UserManager()

    def get_full_name(self):
        return self.name

    def get_short_name(self):
        return self.name
Exemplo n.º 16
0
class UploadCustomDataForm(forms.Form):
    """Upload custom data files form class."""
    database = forms.CharField(label='Enter database name', validators=[validators.validate_slug])
    gene_set = forms.FileField(
        label='Gene set file',
        validators=[validators.FileExtensionValidator([CSV, TSV, TXT])],
        help_text="<strong>Supported file formats:</strong> *.csv *.tsv or *.txt."
    )
Exemplo n.º 17
0
class ExcelStatus(models.Model):
    name = models.CharField(max_length=50, default="", verbose_name="EXCEL 名称")
    add_time = models.DateTimeField(default=timezone.now, verbose_name="创建日期")
    xl_file = models.FileField(upload_to="%Y/%m/%d/", validators=[
        validators.FileExtensionValidator(['xlsx', 'csv'])
    ], verbose_name="EXCEL 文件")
    recite_time = models.DateTimeField(default=datetime(2000, 1, 1, 1, 1, 1, 1), verbose_name="背诵日期")
    pdf_file = models.FileField(upload_to="pdfs/", validators=[
        validators.FileExtensionValidator(['pdf'])
    ], null=False, default="None", help_text="单词本")
    ans_file = models.FileField(upload_to="pdfs/", validators=[
        validators.FileExtensionValidator(['pdf'])
    ], null=False, default="None", help_text="答案本")
    owner = models.ForeignKey(UserProfile, on_delete=models.DO_NOTHING, related_name="owner", verbose_name="所有者")

    def __str__(self):
        return self.name
Exemplo n.º 18
0
class Article(models.Model):

    title = models.CharField(max_length=100)
    content = models.TextField()
    # thumbnial = models.FileField(upload_to='files')
    thumbnial = models.FileField(
        upload_to='%Y/%m/%d',
        validators=[validators.FileExtensionValidator(['txt', 'png'])])
Exemplo n.º 19
0
class Article(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()
    thumbnail = models.FileField(upload_to='files',
                                 validators=[
                                     validators.FileExtensionValidator(
                                         ['jpg', 'png', 'gid'],
                                         message="必须是上述格式文件图片")
                                 ])
Exemplo n.º 20
0
class UploadImagesForm(forms.Form):
    file = forms.FileField(
        widget=forms.ClearableFileInput(attrs={"multiple": True}),
        validators=[
            dj_validators.FileExtensionValidator([
                "jpeg", "jpg", "png", "svg", "gif", "webp", "tiff", "tif",
                "bmp"
            ])
        ],
    )
Exemplo n.º 21
0
class Upload(models.Model):
    file = models.FileField(
        upload_to="files/",
        validators=[validators.FileExtensionValidator(['pdb'])])
    object_name = models.CharField(
        max_length=200)  # is the file object name, not the file name itself!
    upload_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.object_name
Exemplo n.º 22
0
class Article(models.Model):
    title = models.CharField(max_length=20)
    thumbnail = models.FileField(upload_to='files',
                                 validators=[
                                     validators.FileExtensionValidator(
                                         ['md', 'txt'],
                                         message='上传的文件必须为markdown或者txt文件')
                                 ])

    avatar = models.ImageField(
        upload_to='image',
        null=True,
        blank=True,
        default=None,
        validators=[
            validators.FileExtensionValidator(
                allowed_extensions=['png', 'jpg', 'gif'],
                message='只能上传png, jpg, gif格式的文件')
        ])
Exemplo n.º 23
0
class Work(models.Model):
    work_id = models.OneToOneField('Team',
                                   on_delete=models.CASCADE,
                                   related_name="work")
    add_time = models.DateTimeField(default=timezone.now())
    paper_word = models.FileField("作品word版",
                                  upload_to="word",
                                  null=True,
                                  validators=[
                                      validators.FileExtensionValidator(
                                          ['doc', 'docx'],
                                          message="文件必须为doc/docx格式")
                                  ])

    paper_pdf = models.FileField("作品pdf版",
                                 upload_to="pdf",
                                 null=True,
                                 validators=[
                                     validators.FileExtensionValidator(
                                         ['pdf'], message="文件必须为pdf格式")
                                 ])

    paper_cc = models.FileField("查重报告pdf版",
                                upload_to="cc",
                                null=True,
                                validators=[
                                    validators.FileExtensionValidator(
                                        ['pdf'], message="文件必须为pdf格式")
                                ])
    status = models.CharField('状态', max_length=20, default="未上传")

    #    score_1 = models.PositiveIntegerField("得分1", default = 0)
    #    score_2 = models.PositiveIntegerField("得分2", default = 0)
    #    detail_1 = models.CharField('评价1', max_length = 100, default="")
    #    detail_2 = models.CharField('评价2', max_length = 100, default="")
    #    judge_1_username = models.CharField('评委1', max_length = 20, default="")
    #    judge_2_username = models.CharField('评委2', max_length = 20, default="")
    #    judge1_is_review = models.CharField('评委1是否提交评分', max_length = 2, default="否")
    #    judge2_is_review = models.CharField('评委2是否提交评分', max_length = 2, default="否")

    def __str__(self):
        return self.work_id
Exemplo n.º 24
0
def with_svg_validator(value):
    """
    allows all PIL extensions and svg, if you want to add svgz here you will also need to configure
    THUMBNAIL_PRESERVE_EXTENSIONS setting
    Such a function is used as reference in fields ``validators=[with_svg_validator]
    :param value: value to validate
    :return: the validated value
    """
    return validators.FileExtensionValidator(allowed_extensions=validators.get_available_image_extensions() + ["svg"])(
        value
    )
Exemplo n.º 25
0
class UpFiles(models.Model):
    title = models.CharField(max_length=16)
    # 如果不给它指定 upload_to ,它就会自动 直接 存放字 settings.py 中 MEDIA_ROOT 指定的目录中
    # 如果给它 指定 upload_to,他就会在 MEDIA_ROOT 指定的目录中 创建这些子目录,然后将文件存放进去
    file = models.FileField(upload_to='app6/files',
                            validators=[validators.FileExtensionValidator(['pdf'], message='文件必须为pdf')])

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'app6_file'
Exemplo n.º 26
0
class AbstractUser(BaseAbstractUser):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    email = models.EmailField(_('email address'), unique=True)
    middle_name = models.CharField(
        verbose_name=_("Middle Name"),
        max_length=20,
        validators=[
            validators.RegexValidator(regex=r"^[A-Za-z ]+$", message=_("Enter Valid Middle Name."))],
        null=True,blank=True,
    )
    
    date_of_birth = models.DateField(
        verbose_name=_("Data of Birth"),
        null=True,blank=True,
        validators=[utils.age]
    )
    phone_number = models.CharField(verbose_name=_("Phone Number"),
                                    max_length=13,
                                    null=True,blank=True,
                                    validators=[validators.RegexValidator(
                                        regex=r"^[4-9]\d{9}$", message=_("Enter Valid Phone Number.")), ],
                                    help_text=_("Enter Your Number without <b>country code.</b>")
                                    )
    country = models.CharField(max_length=25, null=True, blank=True)
    state = models.CharField(max_length=50, null=True, blank=True)
    city = models.CharField(max_length=50, null=True, blank=True)
    pincode = models.CharField(verbose_name=_("Pincode"), max_length=6,
                               null=True,blank=True
                               )
    full_address = models.TextField(verbose_name=_("Full Address"),
                                    null=True,
                                    blank=True,
                                    max_length=50,
                                    )
    is_defaulter = models.BooleanField(default=False, help_text=_('User in defaulter list'))
    profile = models.FileField(upload_to=utils.pic_upload,
                               default='user.jpg', blank=True,null=True,
                               validators=[validators.FileExtensionValidator(
                                   allowed_extensions=validators.get_available_image_extensions(),
                                   message=_(
                                       "Select valid Cover Image.")
                               ), utils.profile_size
                               ],)

    def image_tag(self):
        return mark_safe('<img src="{}" width="200px" />'.format(escape(self.profile.url)))
    image_tag.short_description = 'USER IMAGE'
    image_tag.allow_tags = True
   
    class Meta(BaseAbstractUser.Meta):
        verbose_name = _('user')
        verbose_name_plural = _('users')
        abstract = True
Exemplo n.º 27
0
class AvatarForm(forms.ModelForm):
    avatar = forms.ImageField(
        label='Сменить аватар',
        validators=[
            validators.FileExtensionValidator(allowed_extensions=('gif', 'jpg',
                                                                  'png'))
        ],
        error_messages={'invalid_extension': 'Этот формат не поддерживается'})

    class Meta:
        model = UserProfile
        fields = ['avatar']
Exemplo n.º 28
0
class Document(models.Model):
    TYPE_INVOICE = "I"
    TYPE_PICTURE = "P"
    TYPE_OTHER = "O"
    TYPE_CHOICES = (
        (TYPE_INVOICE, _("Facture")),
        (
            TYPE_PICTURE,
            _("Photo ou illustration de l'événement, de la salle, du matériel"
              ),
        ),
        (TYPE_OTHER, _("Autre type de justificatif")),
    )

    title = models.CharField(_("Titre du document"),
                             null=False,
                             blank=False,
                             max_length=200)
    request = models.ForeignKey(
        SpendingRequest,
        on_delete=models.CASCADE,
        related_name="documents",
        related_query_name="document",
        null=False,
        blank=False,
    )

    type = models.CharField(_("Type de document"),
                            blank=False,
                            max_length=1,
                            choices=TYPE_CHOICES)

    file = models.FileField(
        _("Fichier"),
        upload_to=document_path,
        validators=[
            validators.FileExtensionValidator([
                "doc",
                "docx",
                "odt",
                "xls",
                "xlsx",
                "ods",
                "pdf",
                "png",
                "jpeg",
                "jpg",
                "gif",
            ])
        ],
    )

    deleted = models.BooleanField(_("Supprimé"), null=False, default=False)
Exemplo n.º 29
0
class Work(models.Model):
    work_id = models.OneToOneField('Team',
                                   on_delete=models.CASCADE,
                                   related_name="work")
    add_time = models.DateTimeField(default=timezone.now())
    paper_word = models.FileField("作品word版",
                                  upload_to="word",
                                  null=True,
                                  validators=[
                                      validators.FileExtensionValidator(
                                          ['doc', 'docx'],
                                          message="文件必须为doc/docx格式")
                                  ])

    paper_pdf = models.FileField("作品pdf版",
                                 upload_to="pdf",
                                 null=True,
                                 validators=[
                                     validators.FileExtensionValidator(
                                         ['pdf'], message="文件必须为pdf格式")
                                 ])

    paper_cc = models.FileField("查重报告pdf版",
                                upload_to="cc",
                                null=True,
                                validators=[
                                    validators.FileExtensionValidator(
                                        ['pdf'], message="查重报告必须为pdf格式")
                                ])
    paper_commit = models.FileField("承诺书pdf版",
                                    upload_to="commit",
                                    null=True,
                                    validators=[
                                        validators.FileExtensionValidator(
                                            ['pdf'], message="承诺书必须为pdf格式")
                                    ])

    paper_sign_up = models.FileField("报名表word版",
                                     upload_to="sign_up",
                                     null=True,
                                     validators=[
                                         validators.FileExtensionValidator(
                                             ['doc', 'docx'],
                                             message="报名表必须为doc/docx格式")
                                     ])
    paper_game_data = models.FileField("原始数据zip版",
                                       upload_to="game_data",
                                       null=True,
                                       validators=[
                                           validators.FileExtensionValidator(
                                               ['zip', 'rar'],
                                               message="原始数据必须为zip/rar格式")
                                       ])

    status = models.CharField('状态', max_length=20, default="未上传")

    #未上传->已上传->退回/报送

    def __str__(self):
        return self.work_id
Exemplo n.º 30
0
class Team(models.Model):
    team_name = models.CharField(max_length=40,
                                 unique=True,
                                 verbose_name='隊伍名稱')
    team_topic = models.CharField(max_length=50, verbose_name='主題')
    team_school = models.CharField(max_length=40, verbose_name='學校')
    team_teacher = models.CharField(max_length=30, verbose_name='指導教授')
    leader = models.OneToOneField(User,
                                  on_delete=models.CASCADE,
                                  verbose_name='隊長')
    video_link = models.URLField(blank=True, verbose_name='影片簡介')
    code_link = models.URLField(blank=True, verbose_name='原始碼')
    readme = models.FileField(upload_to=user_readme_path,
                              blank=True,
                              verbose_name='說明文件',
                              validators=[
                                  validators.FileExtensionValidator(
                                      ['pdf'], message='必須為pdf格式')
                              ])
    affidavit = models.FileField(upload_to=user_affidavit_path,
                                 blank=True,
                                 verbose_name='切結書',
                                 validators=[
                                     validators.FileExtensionValidator(
                                         ['pdf'], message='必須為pdf格式')
                                 ])
    team_group = models.CharField(max_length=10, blank=True, verbose_name='組別')
    stu_check = models.BooleanField(default=False)
    ppt_link = models.URLField(blank=True, verbose_name='簡報')
    present = models.FileField(upload_to=present_path,
                               blank=True,
                               verbose_name='海報',
                               validators=[
                                   validators.FileExtensionValidator(
                                       ['pdf'], message='必須為pdf格式')
                               ])

    def __str__(self):
        return self.team_name