예제 #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
파일: forms.py 프로젝트: babykick/pycon
 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
파일: forms.py 프로젝트: miyanda2/pyconng
 class Meta:
     model = TalkProposal
     fields = [
         "title",
         "audience_level",
         "description",
         "abstract",
         "additional_notes",
         "special_requirements",
         "recording_release",
     ]
     widgets = {
         "abstract": MarkItUpWidget(),
         "additional_notes": MarkItUpWidget(),
     }
예제 #10
0
파일: forms.py 프로젝트: wenlien/PyConTW
 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
파일: forms.py 프로젝트: babykick/pycon
 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
파일: forms.py 프로젝트: bpoetz/2013-web
 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
파일: forms.py 프로젝트: plounze/scipy-2013
 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
파일: admin.py 프로젝트: iselu/bambu-tools
    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
파일: forms.py 프로젝트: jasonamyers/pytn
 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'}))