Пример #1
0
class ProjectAdminForm(forms.ModelForm):
    description = forms.CharField(widget=MarkItUpWidget(),
                                  help_text=markdown_help_text)
    instructions = forms.CharField(widget=MarkItUpWidget(),
                                   required=False,
                                   help_text=markdown_help_text)

    class Meta:
        model = Project
Пример #2
0
class RecipeForm(forms.ModelForm):
    description = forms.CharField(widget=MarkItUpWidget())
    ingredients = forms.CharField(widget=MarkItUpWidget())
    directions = forms.CharField(widget=MarkItUpWidget())
    tags = TagField(widget=AutoCompleteTagInput())
    captcha = ReCaptchaField(label="Please let us know you are a real person")

    class Meta:
        model = Recipe
        exclude = ('approved', 'slug')
Пример #3
0
class FormResource(AjaxModelForm):
    description = forms.CharField(widget=MarkItUpWidget())
    kind = forms.CharField(required=False, widget=AutocompleteWithFavorites(
            ResourceKind, '/resource/search_by_kind/',
            ResourceKind.favorites(number=10), can_add=True))
    contact = forms.CharField(required=False, widget=MarkItUpWidget())
    tags = forms.Field(required=False, widget=TaggitWidget(
            autocomplete_url="/resource/search_tags/"))
    community = AutoCompleteSelectMultipleField('community', help_text='',
        required=False)
    files = FileuploadField(required=False)

    class Meta:
        model = Resource
        fields = ('name', 'description', 'kind', 'contact', 'tags', 'community',
            'id', 'files')

    _field_labels = {
        'name': _('Name'),
        'description': _('Description'),
        'kind': _('Kind'),
        'contact': _('Contact'),
        'tags': _('Tags'),
        'community': _('Community'),
        'files': _('Images'), }

    def __init__(self, *args, **kwargs):
        self.helper = MooHelper(form_id='form_resource')
        r = super(FormResource, self).__init__(*args, **kwargs)
        self.fields['name'].initial = ''
        return r

    @notify_on_update
    def save(self, *args, **kwargs):
        resource = super(FormResource, self).save(*args, **kwargs)
        UploadedFile.bind_files(
            self.cleaned_data.get('files', '').split('|'), resource)
        return resource

    def clean_kind(self):
        field_data = self.cleaned_data['kind']
        model = ResourceKind
        can_add = self.fields['kind'].widget.can_add
        try:
            if not field_data or field_data == 'None':
                if can_add and self.data.get('kind_autocomplete', ''):
                    new_kind = model(name=self.data['kind_autocomplete'])
                    new_kind.save()
                    return new_kind
                else:
                    return model()
            else:
                return model.objects.get(pk=field_data)
        except:
            raise forms.ValidationError(_('invalid field data'))
Пример #4
0
 class Meta:
     model = OpenSpaceProposal
     fields = [
         "title",
         "description",
         "abstract",
         "additional_notes",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #5
0
 class Meta:
     model = PyConSponsorTutorialProposal
     fields = [
         "title",
         "description",
         "abstract",
         "additional_notes",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #6
0
 class Meta:
     model = StandProposal
     fields = [
         "title",
         "organisation",
         "description",
         "abstract",
         "additional_notes",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #7
0
 class Meta:
     model = models.TutorialProposal
     fields = [
         "title",
         "audience_level",
         "description",
         "abstract",
         "additional_notes",
         "recording_release",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #8
0
class FormProject(AjaxModelForm):
    description = forms.CharField(widget=MarkItUpWidget())
    contact = forms.CharField(required=False, widget=MarkItUpWidget())
    tags = forms.Field(
        required=False,
        widget=TaggitWidget(autocomplete_url="/project/search_tags/"))
    logo = FileuploadField(required=False, widget=SingleFileUploadWidget)
    partners_logo = FileuploadField(required=False)

    class Meta:
        model = Project
        fields = ('name', 'description', 'tags', 'contact', 'logo', 'id')

    _field_labels = {
        'name': _('Name'),
        'description': _('Description'),
        'tags': _('Tags'),
        'logo': _('Logo'),
        'contact': _('Contact'),
        'partners_logo': _('Partners Logo'),
    }

    def __init__(self, *a, **kw):
        self.helper = MooHelper(form_id='form_project')
        return super(FormProject, self).__init__(*a, **kw)

    def save(self, *a, **kw):
        proj = super(FormProject, self).save(*a, **kw)
        UploadedFile.bind_files(
            self.cleaned_data.get('partners_logo', '').split('|'), proj)
        return proj

    def clean_logo(self):
        return clean_autocomplete_field(self.cleaned_data['logo'],
                                        UploadedFile)

    def clean(self):
        super(FormProject, self).clean()
        try:
            if not self.cleaned_data['id']:
                self.validation(
                    'name', u'O sistema já possui um projeto com este nome',
                    Project.objects.filter(
                        Q(name__iexact=self.cleaned_data['name'])
                        | Q(slug=slugify(self.cleaned_data['name']))).count())
        except Exception as err:
            logger.error('Validation Error: {}'.format(err))
        finally:
            return self.cleaned_data
Пример #9
0
 class Meta:
     model = TalkProposal
     fields = [
         "title",
         "audience_level",
         "description",
         "abstract",
         "additional_notes",
         "special_requirements",
         "recording_release",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #10
0
 class Meta:
     model = Proposal
     fields = [
         "title",
         "category",
         "audience_level",
         "description",
         "abstract",
         "additional_notes",
     ]
     widgets = {
         "description": forms.Textarea(attrs={'class': 'input-xxlarge'}),
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #11
0
 class Meta:
     model = Proposal
     fields = [
         "title",
         "format",
         "category",
         "description",
         "abstract",
         "additional_notes",
         # "recording_release",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #12
0
 class Meta:
     model = PyConPosterProposal
     fields = [
         "title",
         "category",
         "audience_level",
         "description",
         "abstract",
         "additional_notes",
         "recording_release",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
Пример #13
0
class CodehubTopicForm(forms.ModelForm):
    CHOICES = (
        ('', '--Select Type--'),
        ('Basic', 'Basic'),
        ('Advanced', 'Advanced'),
    )
    topic_heading = forms.CharField(
        label='',
        max_length=100,
        widget=forms.TextInput(
            attrs={'placeholder': 'Topic heading goes here..'}))
    topic_detail = forms.CharField(
        label='',
        widget=MarkItUpWidget(
            attrs={'placeholder': 'Topic details goes here'}))
    topic_link = forms.URLField(
        label='',
        max_length=100,
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'Link to topic'}))
    tags = TagField(
        label='',
        widget=TagWidget(
            attrs={'placeholder': 'Give some Tags(separated by commas)'}))
    topic_type = forms.ChoiceField(label='', choices=CHOICES, required=True)
    file = forms.FileField(label='Upload a file:', required=False)

    class Meta:
        model = CodehubTopicModel
        fields = [
            'topic_heading', 'topic_detail', 'topic_link', 'tags',
            'topic_type', 'file'
        ]
Пример #14
0
class BugForm(forms.ModelForm, FormMixin):
    def save(self, commit=True):
        newo = super(BugForm, self).save(commit=commit)
        if newo.created_dt == None:
            newo.created_dt = datetime.datetime.now()
        newo.modified_dt = datetime.datetime.now()
        return newo

    class Meta:
        model = Bug
        exclude = ('parent_pk', 'parent_type', 'user', 'child', 'children',
                   'permission_req', 'created_dt', 'modified_dt',
                   'deadline_dt')

    form_id = forms.CharField(widget=forms.HiddenInput(),
                              initial="pp_bug_form")
    summary = forms.CharField(max_length=100,
                              widget=forms.TextInput(attrs={
                                  'size': '50',
                                  'class': 'inputText'
                              }),
                              label="Title")
    description = forms.CharField(widget=MarkItUpWidget(),
                                  label="Bug Description")
    location = forms.CharField(label="URL that caused error",
                               max_length=100,
                               widget=forms.TextInput(attrs={
                                   'size': '50',
                                   'class': 'inputText'
                               }),
                               required=False)
Пример #15
0
class DevhubQuestionForm(forms.ModelForm):
    CHOICES = (('', '--Select Type--'), ('Basic', 'Basic'),
               ('Intermediate', 'Intermediate'), ('Advanced', 'Advanced'))
    question_heading = forms.CharField(
        label='',
        widget=forms.TextInput(attrs={'placeholder': 'Question Heading'}),
        max_length=200)
    question_description = forms.CharField(
        label='',
        widget=MarkItUpWidget(
            attrs={'placeholder': 'Question Details goes here...'}))
    question_link = forms.URLField(
        label='',
        widget=forms.TextInput(attrs={'placeholder': 'Question Link'}),
        max_length=100,
        required=False)
    question_tags = TagField(
        label='', widget=TagWidget(attrs={'placeholder': 'Enter Tags'}))
    question_type = forms.ChoiceField(label='', choices=CHOICES)

    class Meta:
        model = DevhubQuestionModel
        fields = [
            'question_heading', 'question_description', 'question_link',
            'question_tags', 'question_type'
        ]
Пример #16
0
 class Meta:
     model = Page
     fields = ["title", "body", "path"]
     widgets = {
         "body": MarkItUpWidget(),
         "path": forms.HiddenInput(),
     }
Пример #17
0
class ProposalForm(AjaxModelForm):
    description = CharField(widget=MarkItUpWidget())
    need = CharField(widget=HiddenInput())
    contacts = CharField(required=False, widget=ContactsWidget())
    tags = Field(
        widget=TaggitWidget(autocomplete_url="/proposal/search_tags/"),
        required=False)

    class Meta:
        model = Proposal
        fields = ('title', 'short_description', 'description', 'contacts',
                  'cost', 'need', 'tags')

    _field_labels = {
        'title': _('Title'),
        'description': _('Description'),
        'short_description': _('Short description'),
        'contacts': _('Contacts'),
        'tags': _('Tags'),
        'cost': _('Cost'),
        'need': ' '
    }

    def __init__(self, *a, **kw):
        # Crispy forms configuration
        self.helper = MooHelper(form_id="proposal_form")
        return super(ProposalForm, self).__init__(*a, **kw)

    @notify_on_update
    def save(self, *a, **kw):
        return super(ProposalForm, self).save(*a, **kw)

    def clean_need(self):
        return clean_autocomplete_field(self.cleaned_data['need'], Need)
Пример #18
0
class FormProfile(AjaxModelForm):
    about_me = forms.CharField(required=False, widget=MarkItUpWidget())
    name = forms.CharField(required=False)
    geometry = forms.CharField(required=False, widget=MapButtonWidget)
    #geometry = forms.CharField(required=False, widget=forms.HiddenInput())
    contacts = forms.CharField(required=False, widget=ContactsWidget())
    photo = FileuploadField(required=False)

    class Meta:
        model = User
        fields = ['name', 'about_me', 'id', 'geometry', 'contacts']

    _field_labels = {
        'name': _('Full name'),
        'about_me': _('About me'),
        'photo': _('Photo'),
        'geometry': _('Location'),
        'contacts': _('Contacts'),
    }

    def __init__(self, *a, **kw):
        self.helper = MooHelper(form_id='form-profile')
        self.helper.form_action = reverse('profile_update_public_settings')
        super(FormProfile, self).__init__(*a, **kw)
        inst = kw.get('instance', None)
        if inst and not inst.name:
            self.fields['public_name'].initial = inst.user.name

    def save(self, *args, **kwargs):
        profile = super(FormProfile, self).save(*args, **kwargs)
        UploadedFile.bind_files(
            self.cleaned_data.get('photo', '').split('|'), profile)
        return profile
Пример #19
0
 class Meta:
     model = TutorialProposal
     fields = [
         "title",
         "track",
         "description",
         "abstract",
         "package_list",
         "additional_notes",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
         "description": forms.widgets.Textarea(attrs={"class": "span9"}),
         "package_list": forms.widgets.Textarea(attrs={"class": "span9"}),
     }
Пример #20
0
class ProposalForm(AjaxModelForm):
    description = CharField(widget=MarkItUpWidget())
    need = CharField(widget=HiddenInput())

    class Meta:
        model = Proposal
        fields = ('title', 'description', 'cost', 'need')

    _field_labels = {
        'title': _('Title'),
        'description': _('Description'),
        'cost': _('Cost'),
        'need': ' '
    }

    def __init__(self, *a, **kw):
        # Crispy forms configuration
        self.helper = MooHelper(form_id="proposal_form")
        return super(ProposalForm, self).__init__(*a, **kw)

    @notify_on_update
    def save(self, *a, **kw):
        return super(ProposalForm, self).save(*a, **kw)

    def clean_need(self):
        return clean_autocomplete_field(self.cleaned_data['need'], Need)
Пример #21
0
 class Meta:
     model = Talk
     fields = ('title', 'talk_type', 'abstract', 'authors', 'notes')
     widgets = {
         'abstract': MarkItUpWidget(),
         'notes': forms.Textarea(attrs={'class': 'input-xxlarge'}),
     }
Пример #22
0
class BlobEditForm(forms.ModelForm):
    def save(self, commit=True):
        newo = super(BlobEditForm, self).save(commit=commit)
        if newo.created_dt == None:
            newo.created_dt = datetime.datetime.now()
            ctype = ContentType.objects.get_for_model(Nomination)
            newo.child = ctype
            newo.children = 0
        newo.modified_dt = datetime.datetime.now()
        return newo

    class Meta:
        model = Question
        exclude = ('parent', 'parent_pk', 'parent_type', 'user', 'child',
                   'children', 'permission_req', 'created_dt', 'modified_dt',
                   'forumdimension')

    blobsummary = forms.CharField(max_length=100,
                                  widget=forms.TextInput(attrs={
                                      'size': '70',
                                      'class': 'inputText'
                                  }),
                                  initial="")
    blobdescription = forms.CharField(widget=MarkItUpWidget(attrs={
        'cols': '20',
        'rows': '10'
    }),
                                      initial="",
                                      label="Description")
Пример #23
0
class CommunityForm(AjaxModelForm):
    class Meta:
        model = Community
        fields = ('name', 'population', 'description', 'tags', 'geometry',
                  'files')

    _field_labels = {
        'name': _('Name'),
        'description': _('Description'),
        'population': _('Population'),
        'tags': _('Tags'),
        'files': _(' '),
    }

    description = forms.CharField(widget=MarkItUpWidget())
    geometry = forms.CharField(widget=forms.HiddenInput())
    files = FileuploadField(required=False)
    tags = forms.Field(
        widget=TaggitWidget(autocomplete_url="/community/search_tags/"),
        required=False)

    def __init__(self, *a, **kw):
        self.helper = MooHelper(form_id="community_form")
        return super(CommunityForm, self).__init__(*a, **kw)

    @notify_on_update
    def save(self, *args, **kwargs):
        comm = super(CommunityForm, self).save(*args, **kwargs)
        UploadedFile.bind_files(
            self.cleaned_data.get('files', '').split('|'), comm)
        return comm
Пример #24
0
    def __init__(self, *a, **kw):
        retorno = super(FormComment, self).__init__(*a, **kw)

        # id_ = self.instance.id if self.instance else ''

        self.fields['comment'].widget = MarkItUpWidget()
        return retorno
Пример #25
0
    def __init__(self, *args, **kwargs):
        def add_choices(queryset, indent=0):
            if self.instance:
                queryset = queryset.exclude(pk=self.instance.pk)

            for page in queryset:
                choices.append((page.pk, ('-- ' * indent) + page.name))
                add_choices(page.children.all(), indent + 1)

        super(PageAdminForm, self).__init__(*args, **kwargs)
        choices = [('', '---------')]
        queryset = self.fields['parent'].queryset
        add_choices(queryset.root())
        self.fields['parent'].widget.choices = choices

        if 'markitup' in settings.INSTALLED_APPS:
            from markitup.widgets import MarkItUpWidget
            self.fields['body'].widget = MarkItUpWidget()
        elif 'grappelli' in settings.INSTALLED_APPS:
            classes = self.fields['css'].widget.attrs.get('class',
                                                          '').split(' ')
            classes.append('mceNoEditor')
            self.fields['css'].widget.attrs['class'] = ' '.join(
                set(sorted(classes)))

        self.fields['css'].label = u'Custom CSS'
        self.fields[
            'menu_groups'].help_text = u'A comma-separated name of menu groups'
Пример #26
0
 class Meta:
     model = TalkPosterProposal
     fields = [
         "title",
         "description",
         "abstract",
         "submission_type",
         "topic_track",
         "domain_symposium",
         "additional_notes",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "description": forms.widgets.Textarea(attrs={"class": "span9"}),
         "additional_notes": MarkItUpWidget(),
     }
Пример #27
0
class SceneForm(forms.ModelForm, FormMixin):
    def save(self, commit=True):
        newo = super(SceneForm, self).save(commit=commit)
        if newo.created_dt == None:
            newo.created_dt = datetime.datetime.now()
        newo.modified_dt = datetime.datetime.now()
        return newo

    class Meta:
        model = Scene
        exclude = ('parent', 'parent_pk', 'parent_type', 'user', 'child',
                   'children', 'permission_req', 'created_dt', 'modified_dt',
                   'deadline_dt')

    form_id = forms.CharField(widget=forms.HiddenInput(),
                              initial="pp_scene_form")
    summary = forms.CharField(max_length=100,
                              widget=forms.TextInput(attrs={
                                  'size': '70',
                                  'class': 'inputText'
                              }),
                              label="Summary of Scene")
    description = forms.CharField(
        widget=MarkItUpWidget(),
        label="Embed Image, Video, and/or Description")
    location = forms.CharField(label="Location of Scene",
                               max_length=100,
                               widget=forms.TextInput(attrs={
                                   'size': '70',
                                   'class': 'inputText'
                               }),
                               required=False)
Пример #28
0
class BoxForm(forms.ModelForm):

    content = forms.CharField(widget=MarkItUpWidget())

    class Meta:
        model = Box
        fields = ["content"]
Пример #29
0
 class Meta:
     model = Sticker
     fields = ["title", "description", "upload"]
     widgets = {
         "description": MarkItUpWidget(),
         "upload": AdminFileWidget(),
     }
Пример #30
0
class DevhubTopicForm(forms.ModelForm):
    topic_heading = forms.CharField(
        label='',
        max_length=100,
        widget=forms.TextInput(
            attrs={'placeholder': 'Topic heading goes here..'}))
    topic_detail = forms.CharField(
        label='',
        widget=MarkItUpWidget(attrs={
            'placeholder': 'Topic details goes here',
            'style': ''
        }))
    topic_link = forms.URLField(
        label='',
        max_length=100,
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'Link to topic'}))
    tags = TagField(
        label='',
        widget=TagWidget(
            attrs={'placeholder': 'Give some Tags(separated by commas)'}))
    file = forms.FileField(label='Upload a file:', required=False)

    class Meta:
        model = DevhubTopicModel
        fields = [
            'topic_heading', 'topic_detail', 'topic_link', 'tags', 'file'
        ]
Пример #31
0
 def test_per_widget_auto_preview_override(self):
     widget = MarkItUpWidget(auto_preview=self.auto_preview_override)
     self.assertIn(AutoPreviewSettingTests.look_for,
                   widget.render('name', 'value', {'id': 'my_id'}),
                   reverse=not self.auto_preview_override)
Пример #32
0
 def test_widget_render_with_custom_id(self):
     widget = MarkItUpWidget(attrs={'id': 'my_id'})
     self.assertIn(self.look_for,
                   widget.render('name', 'value'))
Пример #33
0
 def test_widget_render_preview_parser_path(self):
     widget = MarkItUpWidget()
     self.assertIn('mySettings["previewParserPath"] = "/markitup/preview/";',
                   widget.render('name', 'value', {'id': 'my_id'}))
Пример #34
0
 def test_widget_render(self):
     widget = MarkItUpWidget()
     self.assertIn(self.look_for,
                   widget.render('name', 'value', {'id': 'my_id'}))