Пример #1
0
class S3DirectUploadForm(forms.Form):
    """
    Fields for uploading images
    """
    image01 = forms.URLField(widget=S3DirectWidget(dest='images_destination'))
    image02 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image03 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image04 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image05 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image06 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image07 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image08 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image09 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)
    image10 = forms.URLField(widget=S3DirectWidget(dest='images_destination'),
                             required=False)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for f in self.fields.values():
            w = f.widget
            w.attrs.update({
                'class': 'form-control',
            })
Пример #2
0
class PhilipsDataForm(forms.ModelForm):

    project_name = forms.CharField(label="Project Name", required=True)
    fullysampled = forms.NullBooleanField(label="Fully Sampled")
    funding_support = forms.CharField(label="Funding Support", required=False)

    if settings.USE_AWS:
        philips_lab_file = forms.URLField(
            widget=S3DirectWidget(dest='uploads'), label="Philips Lab File")
        philips_raw_file = forms.URLField(
            widget=S3DirectWidget(dest='uploads'), label="Philips Raw File")
        philips_sin_file = forms.URLField(
            widget=S3DirectWidget(dest='uploads'), label="Philips Sin File")
    else:
        philips_lab_file = forms.FileField(widget=forms.ClearableFileInput(),
                                           label="Philips Lab File")
        philips_raw_file = forms.FileField(widget=forms.ClearableFileInput(),
                                           label="Philips Raw File")
        philips_sin_file = forms.FileField(widget=forms.ClearableFileInput(),
                                           label="Philips Sin File")

    class Meta:
        if settings.USE_AWS:
            model = PhilipsAwsData
        else:
            model = PhilipsData
        fields = (
            'project_name',
            'anatomy',
            'fullysampled',
            'references',
            'comments',
            'funding_support',
            'philips_lab_file',
            'philips_raw_file',
            'philips_sin_file',
            'thumbnail_horizontal_flip',
            'thumbnail_vertical_flip',
            'thumbnail_transpose',
        )
        widgets = {
            'references': forms.Textarea(attrs={
                'rows': 2,
                'cols': 50
            }),
            'comments': forms.Textarea(attrs={
                'rows': 2,
                'cols': 50
            }),
            'funding_support': forms.Textarea(attrs={
                'rows': 2,
                'cols': 50
            }),
        }
Пример #3
0
class UploadDataset(forms.Form):
    FORMAT_CHOICES = (("states_v1", "States"), ("uscitieslist_csv_v0",
                                                "Cities"),
                      ("openstates_subjects_v1", "Openstates Subjects"))
    small_test = forms.BooleanField(required=False)
    format_id = forms.ChoiceField(choices=FORMAT_CHOICES)
    data_file = forms.URLField(widget=S3DirectWidget(dest="data_upload"))
Пример #4
0
class VideoCreateForm(forms.ModelForm):
    video_file = forms.URLField(widget=S3DirectWidget(
        dest='primary_destination'))

    def form_filename(self):
        cut = len(settings.AWS_S3_ENDPOINT_URL) + len('/') + len(
            settings.AWS_STORAGE_BUCKET_NAME) + len('/')
        cut += len('input/')  # obtained from primary destination

        file_url = self.cleaned_data['video_file']
        cut_file_extension = 0
        for c in reversed(file_url):
            cut_file_extension += 1
            if c == '.':
                break
        cut_file_extension = len(file_url) - cut_file_extension

        fileurl_without_extension = file_url[:cut_file_extension]

        return fileurl_without_extension[cut:]

    def clean_video_file(self):
        data = self.form_filename()
        print('data = ' + data)
        # if not data.isalnum():
        if not re.match(r'^\w+$', data):
            raise forms.ValidationError(
                "The file name should only contain letters and numbers, NO SPACES or SPECIAL CHARACTERS!"
            )
        return data

    class Meta:
        model = Video
        fields = ('video_title', 'video_file', 'comments')
Пример #5
0
 def __init__(self, *args, **kwargs):
     dest = kwargs.pop('dest', None)
     path = ''
     if 'path' in kwargs:
         path = kwargs.pop('path', '')
     self.widget = S3DirectWidget(dest=dest, path=path)
     super(S3DirectField, self).__init__(*args, **kwargs)
Пример #6
0
class AdvertForm(forms.ModelForm):

    skills = forms.ModelMultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(), queryset=Skill.objects.all())
    deadline = forms.DateTimeField(widget=forms.widgets.SelectDateWidget(),
                                   initial=timezone.now())
    image = forms.URLField(widget=S3DirectWidget(
        dest='cause-advert-images',
        html=
        ('<div class="s3direct" data-policy-url="{policy_url}">'
         '  <a class="file-link" target="_blank" href="{file_url}">{file_name}</a>'
         '  <a class="file-remove" href="#remove">Remove</a>'
         '  <input class="file-url" type="hidden" value="{file_url}" id="{element_id}" name="{name}" />'
         '  <input class="file-dest" type="hidden" value="{dest}">'
         '  <input class="file-input js-input-file inputfile" type="file" id="file" name="file"/>'
         '  <label for="file" class="button button--primary">Upload Ad Image</label>'
         '  <div class="progress progress-striped active">'
         '    <div class="bar"></div>'
         '  </div>'
         '</div>')),
                           required=False)

    class Meta:
        model = Advert
        fields = ('title', 'description', 'image', 'skills', 'deadline')
Пример #7
0
class GeDataForm(forms.ModelForm):
    
    project_name = forms.CharField()
    if settings.USE_AWS:
        ge_file = forms.URLField(widget=S3DirectWidget(dest='uploads'))
    else:
        ge_file = forms.FileField(widget=forms.ClearableFileInput())

    class Meta:
        if settings.USE_AWS:
            model = GeAwsData
        else:
            model = GeData
        fields = [
            'project_name',
            'anatomy',
            'fullysampled',
            'references',
            'comments',
            'funding_support',
            'ge_file',
            'thumbnail_horizontal_flip',
            'thumbnail_vertical_flip',
            'thumbnail_transpose',
        ]
        widgets = {
            'references': forms.Textarea(attrs={'rows':3, 'cols':50}),
            'comments': forms.Textarea(attrs={'rows':3, 'cols':50}),
            'funding_support': forms.Textarea(attrs={'rows':3, 'cols':50}),
        }
Пример #8
0
class CreateProjectForm(forms.Form):
    name = forms.CharField(max_length=500)
    url = forms.URLField()
    screenshot = forms.URLField(widget=S3DirectWidget(dest="file_upload"))
    first_paragraph = forms.CharField(widget=Textarea)
    tag1 = cf.tag_aac.get_new_form_field(required=False)
    tag2 = cf.tag_aac.get_new_form_field(required=False)
    tag3 = cf.tag_aac.get_new_form_field(required=False)
Пример #9
0
class NewRecordForm(forms.ModelForm):
    file = forms.URLField(widget=S3DirectWidget(dest='whalejams'))

    class Meta:
        model = Recording
        fields = ('file', 'species', 'population', 'subPopulations', 'lat',
                  'lon', 'date', 'time', 'equipment', 'description',
                  'commType')
Пример #10
0
class CommunityInstanceCreationForm(forms.ModelForm):
	photo = forms.URLField(widget=S3DirectWidget(dest='community'))
	class Meta:
		model = CommunityInst
		exclude = ('spectrum_id', 'occuring_games')
		widgets = {
			'date': forms.DateInput(attrs={'class': 'datepicker'}),
		}
Пример #11
0
class CreateProjectForm(forms.Form):
    tool_name = forms.CharField(max_length=100)
    tool_url = forms.URLField(max_length=200)
    tool_category = forms.ChoiceField(choices=TOOL_CATEGORIES)
    project_category = forms.ChoiceField(choices=PROJECT_CATEGORIES)
    tag1 = cf.tag_aac.get_new_form_field(required=False)
    tag2 = cf.tag_aac.get_new_form_field(required=False)
    tag3 = cf.tag_aac.get_new_form_field(required=False)
    youtube_video_id = forms.CharField(max_length=100, required=False)
    screenshot = forms.URLField(widget=S3DirectWidget(dest="file_upload"))
    summary = forms.CharField(widget=Textarea)
Пример #12
0
class S3DirectUploadForm(forms.Form):
    docfile = forms.URLField(widget=S3DirectWidget(dest='files',
    html=(  '<div class="s3direct" data-policy-url="{policy_url}">'
            '  <a class="file-link" target="_blank" href="{file_url}">{file_name}</a>'
            '  <a class="file-remove" href="#remove">Remove</a>'
            '  <input class="file-url" type="hidden" value="{file_url}" id="{element_id}" name="{name}" />'
            '  <input class="file-dest" type="hidden" value="{dest}">'
            '  <input class="file-input" type="file" />'
            '  <div class="progress progress-striped active">'
            '    <div class="bar"></div>'
            '  </div>'
            '</div>'
        )))
Пример #13
0
 def __init__(self, *args, **kwargs):
     super(CreateProjectForm, self).__init__(*args, **kwargs)
     for i in range(1,4):
         # quote and fallacy fields
         self.fields["quote"+str(i)] = forms.CharField(widget=Textarea(attrs={"rows": 2}), required=False)
         self.fields["speaker_name"+str(i)] = forms.CharField(max_length=500, required=False)
         self.fields["reference"+str(i)] = forms.URLField(required = False)
         self.fields["screenshot_filename"+str(i)] = forms.URLField(widget=S3DirectWidget(dest="file_upload"), required=False)
         self.fields["youtube_video_id"+str(i)] = forms.CharField(max_length=100, required=False)
         self.fields["fallacy"+str(i)] = forms.ModelChoiceField(queryset=Fallacy.objects.all(), required=False)
         self.fields["fallacy_association_explanation"+str(i)] = forms.CharField(widget = Textarea(attrs={"rows": 2}), required=False)
         self.fields["fallacy_association_improvement"+str(i)] = forms.CharField(widget = Textarea(attrs={"rows": 2}), required=False)
     for i in range(1,4):     # separate loops for field ordering
         # tags
         self.fields["tag"+str(i)] = cf.tag_aac.get_new_form_field(required=False)
Пример #14
0
class EditProjectForm(forms.Form):

    name = forms.CharField(label="Project Name")
    fiscal_period_start = forms.DateField(widget=wf.DatePickerJQueryWidget)
    fiscal_period_end = forms.DateField(widget=wf.DatePickerJQueryWidget)

    budget_description = forms.CharField(widget=Textarea(
        attrs={
            'style': "width:100%;",
            'rows': 4,
            'cols': 2
        }))
    revenues_description = forms.CharField(widget=Textarea(
        attrs={
            'style': "width:100%;",
            'rows': 4,
            'cols': 2
        }))
    funds_description = forms.CharField(widget=Textarea(
        attrs={
            'style': "width:100%;",
            'rows': 4,
            'cols': 2
        }))
    expenses_description = forms.CharField(widget=Textarea(
        attrs={
            'style': "width:100%;",
            'rows': 4,
            'cols': 2
        }))

    download_link_1 = wf.InlineLinkField(required=False,
                                         label="Example Budget Excel File")
    download_link_2 = wf.InlineLinkField(required=False,
                                         label="Current Budget Excel File")
    budget_excel_file = forms.URLField(
        label="Replacement Budget Excel File (Optional)",
        required=False,
        widget=S3DirectWidget(dest="file_upload"))
    budget_url = forms.URLField()
    city = cf.tag_aac.get_new_form_field(required=False)
Пример #15
0
class DatapointLargeFileUploadForm(ModelForm):
    large_file = forms.URLField(
        widget=S3DirectWidget(dest='all'),
        required=True,
    )

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-10'
        self.helper.form_method = 'post'
        self.helper.layout = Layout(
            Fieldset(
                ("Upload a Video/Audio Datapoint"),
                'project',
                'name',
                'filetype',
                'large_file',
                'description',
                'author',
                'source',
                'url',
            ),
            ButtonHolder(
                Submit('save', ('Upload datapoint'),
                       css_class='btn btn-primary pull-right'), ))
        super(DatapointLargeFileUploadForm, self).__init__(*args, **kwargs)

    class Meta:
        model = Datapoint
        fields = (
            'project',
            'name',
            'filetype',
            'large_file',
            'description',
            'author',
            'source',
            'url',
        )
Пример #16
0
class ArtifactCreateForm(ModelForm):
    name = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'})
    )
    description = forms.CharField(
        widget=forms.Textarea(attrs={'class': 'form-control'})
    )
    file = forms.URLField(
        widget=S3DirectWidget(dest='misc', attrs={'class': 'form-control-file'})
    )
    created_by = forms.ModelChoiceField(
        User.objects.all(),
        widget=forms.Select(attrs={'class': 'form-control'})
    )
    tags = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'})
    )

    class Meta:
        model = Artifact
        fields = '__all__'
Пример #17
0
from django import forms

from network_search.core import choices
from network_search.affiliates import models
from network_search.core.forms import SearchForm

try:
    from s3direct.widgets import S3DirectWidget
except ImportError:
    widget = forms.FileInput()
else:
    widget = S3DirectWidget(dest='affiliate_imports')


class ExcelUploadForm(forms.ModelForm):

    data_file = forms.FileField(widget=widget)

    class Meta:
        fields = '__all__'
        model = models.ExcelUpload


class AffiliateAdminForm(forms.ModelForm):
    class Meta:
        model = models.Affiliate
        exclude = ['search_content', 'is_removed']


class SchoolAdminForm(forms.ModelForm):
    service_categories = forms.MultipleChoiceField(
Пример #18
0
class S3DirectUploadForm(forms.Form):
    misc = forms.URLField(widget=S3DirectWidget(dest='misc'))
Пример #19
0
 class Meta:
     model = UserProfile
     exclude = ('user', )
     widgets = {
         'avatr_raw': S3DirectWidget(dest='avatars'),
     }
Пример #20
0
 def __init__(self, *args, **kwargs):
     self.dest = kwargs.pop('dest', None)
     self.expires_in = kwargs.pop('expires_in', 3600)
     self.widget = S3DirectWidget(dest=self.dest)
     super().__init__(*args, **kwargs)
Пример #21
0
class S3DirectUploadForm(forms.Form):
    picture = forms.URLField(widget=S3DirectWidget(dest='AmazonS3'))
Пример #22
0
class UploadFileForm(forms.Form):
    status = forms.URLField(widget=S3DirectWidget(dest='primary_destination'))
Пример #23
0
class S3DirectUploadForm(forms.Form):
    images = forms.URLField(widget=S3DirectWidget(dest='imgs'))
Пример #24
0
 def __init__(self, *args, **kwargs):
     upload_to = kwargs.pop('upload_to', None)
     self.widget = S3DirectWidget(upload_to=upload_to)
     super(S3DirectField, self).__init__(*args, **kwargs)
Пример #25
0
 def __init__(self, *args, **kwargs):
     dest = kwargs.pop('dest', None)
     self.widget = S3DirectWidget(dest=dest)
     super(S3DirectField, self).__init__(*args, **kwargs)
Пример #26
0
class S3DirectUploadForm(forms.Form):
    images = forms.URLField(widget=S3DirectWidget(upload_to='images'))
Пример #27
0
class S3DirectUploadForm(forms.Form):
    images = forms.URLField(widget=S3DirectWidget(dest='example_destination'))
Пример #28
0
class S3DirectUploadForm(Form):
    images = URLField(widget=S3DirectWidget(dest='arquivos_cirurgia'))