File size: 2,455 Bytes
090987a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from django import forms
from .widgets import MultipleFileInput 
from django.core.exceptions import ValidationError


class ImageUploadForm(forms.Form):
    image = forms.ImageField(
        widget=forms.ClearableFileInput(attrs={
            'class': 'form-control',
            'capture': 'user'
        })
    )

class ClassificationForm(forms.Form):
    claim = forms.CharField(
        label="Claim:",
        widget=forms.Textarea(attrs={
            'class': 'form-control',
            'rows': 5,
            'placeholder': 'Enter your claim or statement',
        })
    )

class RegisterFaceForm(forms.Form):
    person = forms.CharField(
        label="Person:",
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'placeholder': 'e.g: ANWAR IBRAHIM',
        })
    )
    keywords = forms.CharField(
        label="Keyword:",
        required=False,
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'placeholder': 'e.g: Prime Minister of Malaysia',
        })
    )
    images = forms.FileField(
        required=False,
        widget=MultipleFileInput(attrs={
            'multiple': True,
            'class': 'form-control',
            'capture': 'user'
        })
    )

class TranscribeForm(forms.Form):
    url = forms.CharField(
        label="YouTube URL:",
        required=False,
        widget=forms.TextInput(attrs={
            'type': 'url',
            'class': 'form-control',
            'placeholder': 'Enter YouTube URL',
            
        })
    )
    file = forms.FileField(
        label="Upload Audio/Video File",
        required=False,
        widget=forms.ClearableFileInput(attrs={
            'class': 'form-control',
            'accept': 'audio/*,video/*',
            
        })
    )
    def clean(self):
        cleaned_data = super().clean()
        url = cleaned_data.get("url")
        file = cleaned_data.get("file")

        if not url and not file:
            raise ValidationError("You must provide either a YouTube URL or upload a file.")
        if url and file:
            raise ValidationError("Please provide only one: YouTube URL or a file upload.")

class YouTubeURLForm(forms.Form):
    youtube_url = forms.URLField(
        label='YouTube Video URL',
        widget=forms.URLInput(attrs={
            'class': 'form-control',
            'placeholder': 'https://www.youtube.com/watch?v=example'
        })
    )