def test_non_default_setting(self):
     with self.settings(**TEST_SETTINGS):
         textarea = Textarea()
         widget = RichTextWidget()
         textarea_out = str(textarea.render("widget", ""))
         widget_out = str(widget.render("widget", ""))
         self.assertEquals(textarea_out, widget_out)
Example #2
0
    def render(self, name, value, attrs=None):

        text_area_widget = Textarea()

        a = None
        ge_attrs = self.build_attrs(a, name="ge_"+name)
        ge = self._build_ge(name, value)
        ge = mark_safe(ge)
        return ge + text_area_widget.render(name, value, {"id": name})
Example #3
0
class CourrierForm(forms.Form):
    message = forms.CharField(widget=Textarea(attrs={'cols': 80, 'rows': 20}))
Example #4
0
 def __init__(self, question, *args, **kwargs):
     super(EssayForm, self).__init__(*args, **kwargs)
     self.fields["answers"] = forms.CharField(widget=Textarea(
         attrs={'style': 'width:100%'}))
Example #5
0
 class Meta:
     model = Post
     fields = [
         'text',
     ]
     widgets = {'text': Textarea(attrs={'cols': 80, 'rows': 20})}
Example #6
0
 def as_textarea(self, attrs=None, **kwargs):
     """Return a string of HTML for representing this as a <textarea>."""
     return self.as_widget(Textarea(), attrs, **kwargs)
Example #7
0
class AbstractEducationalOfferForm(forms.ModelForm):
    eduoffer_position = forms.CharField(
        label=FieldEducationalOffer.POSITION,
        widget=CKEditorWidget(config_name='titles'))
    eduoffer_lead = forms.CharField(label=FieldEducationalOffer.LEAD,
                                    widget=CKEditorWidget(config_name='leads'))
    eduoffer_image_copyright = forms.CharField(
        label=FieldEducationalOffer.IMAGE_COPYRIGHT,
        widget=Textarea(attrs={
            'style': 'height : auto',
            'rows': 2
        }),
        required=False)
    eduoffer_description = forms.CharField(
        label=FieldEducationalOffer.DESCRIPTION,
        widget=CKEditorUploadingWidget())
    eduoffer_keywords = HistoryTagField(label=FieldEducationalOffer.KEYWORDS)
    eduoffer_connected_projects = forms.ModelMultipleChoiceField(
        label=FieldEducationalOffer.CONNECTED_PROJECTS,
        required=False,
        queryset=Project.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(url='project-autocomplete')
    )  # related_name field has to be defined in the form

    def __init__(self, *args, **kwargs):
        if kwargs.get('instance'):
            initial = kwargs.setdefault('initial', {})
            # the widget for a ModelMultipleChoiceField expects a list of primary key for the selected data
            initial['eduoffer_connected_projects'] = [
                project.project_id for project in
                kwargs['instance'].eduoffer_connected_projects.all()
            ]
        super(AbstractEducationalOfferForm, self).__init__(*args, **kwargs)

    def clean_eduoffer_date_end(self):
        try:
            dateFrom = self.cleaned_data.get('eduoffer_date_start', None)
            dateTo = self.cleaned_data.get('eduoffer_date_end', None)
        except:
            raise forms.ValidationError(MessageEducationalOffer.INCORRECT_DATE)
        if dateFrom is not None and dateTo is not None:
            if dateFrom > dateTo:
                raise forms.ValidationError(
                    MessageEducationalOffer.INCORRECT_PERIOD)
        return dateTo

    def _save_m2m(self):
        instance = self.instance
        instance.eduoffer_connected_projects.clear()
        for project in self.cleaned_data['eduoffer_connected_projects']:
            instance.eduoffer_connected_projects.add(project)
        super(AbstractEducationalOfferForm, self)._save_m2m()

    class Meta:
        abstract = True
        model = EducationalOffer
        fields = ('__all__')
        widgets = {
            'eduoffer_institution':
            autocomplete.ModelSelect2(url='institution-autocomplete'),
            'eduoffer_city':
            autocomplete.ModelSelect2(url='city-autocomplete'),
            'eduoffer_type':
            autocomplete.ModelSelect2(url='educationaloffertype-autocomplete'),
            'eduoffer_mode':
            autocomplete.ModelSelect2(url='educationaloffermode-autocomplete'),
        }
        exclude = ('eduoffer_position_text', 'eduoffer_position_slug',
                   'eduoffer_date_add', 'eduoffer_date_edit',
                   'eduoffer_added_by', 'eduoffer_modified_by',
                   'eduoffer_authorizations')
Example #8
0
class ImageAnnotationForm(forms.Form):
    status_list = Status.objects.filter(default=True)

    if status_list:
        default_status = status_list[0]

    #status = forms.ModelChoiceField(queryset=Status.objects.all(),
    #        initial=default_status)
    hand = forms.ModelChoiceField(
        required=False,
        queryset=Hand.objects.all(),
        widget=Select(
            attrs={
                'name': 'hand',
                'class': 'chzn-select hand_form',
                'data-placeholder': "Hand"
            }),
        label="",
        empty_label='------',
    )
    #after = forms.ModelChoiceField(required=False,
    #        queryset=Allograph.objects.all())
    allograph = forms.ModelChoiceField(
        required=False,
        queryset=Allograph.objects.all(),
        widget=AllographSelect(
            attrs={
                'name': 'allograph',
                'class': 'chzn-select allograph_form',
                'data-placeholder': "Allograph"
            }),
        label="",
        empty_label='------',
    )
    #before = forms.ModelChoiceField(required=False,
    #        queryset=Allograph.objects.all())
    #feature = forms.MultipleChoiceField(required=False,
    #        widget=forms.SelectMultiple(attrs={'size': 25}))
    display_note = forms.CharField(required=False,
                                   label="",
                                   widget=Textarea(attrs={
                                       'cols': 25,
                                       'rows': 5,
                                       'class': 'hidden'
                                   }))
    internal_note = forms.CharField(required=False,
                                    label="",
                                    widget=Textarea(attrs={
                                        'cols': 25,
                                        'rows': 5,
                                        'class': 'hidden'
                                    }))

    def clean(self):
        """The feature field is always marked as invalid because the choices
        are populated dinamically on the client side, therefore the clean
        method needs to be overriden to ignore errors related to the feature
        field."""
        super(ImageAnnotationForm, self).clean()

        if 'feature' in self._errors:
            del self._errors['feature']

        return self.cleaned_data
# -*- encoding: utf-8 -*-
from django.forms.widgets import Textarea

SmallerTextarea = Textarea(attrs={'cols': 75, 'rows': 2})
AverageTextarea = Textarea(attrs={'cols': 75, 'rows': 4})
BiggerTextarea = Textarea(attrs={'cols': 75, 'rows': 18})

try:
    from grappelli.forms import GrappelliSortableHiddenMixin as \
        SortableHiddenMixin
except ImportError:

    class SortableHiddenMixin:
        # no-op
        pass
Example #10
0
 class Meta:
     model = models.RightsStatementStatuteInformationNote
     widgets = {
         'statutenote': Textarea(attrs=settings.TEXTAREA_ATTRS), }
Example #11
0
 class Meta:
     model = models.RightsStatementCopyrightNote
     widgets = {
         'copyrightnote': Textarea(attrs=settings.TEXTAREA_ATTRS), }
Example #12
0
 class Meta:
     model = models.RightsStatementLicenseNote
     widgets = {
         'licensenote': Textarea(attrs=settings.TEXTAREA_ATTRS), }
Example #13
0
class refundForm(forms.Form):
    code_to_refund = forms.CharField()
    send_email_line = forms.CharField(widget=Textarea())
    description = forms.CharField(widget=forms.Textarea(attrs={'rows': 4}))
    email_address = forms.EmailField()
Example #14
0
        widget=Textarea))

QUESTION_TITLE_TIPS = Setting(
    'QUESTION_TITLE_TIPS', u"""
 - **ask a question relevant to the |APP_TITLE| community**
 - the title must be in the form of a question
 - provide enough details
 - be clear and concise
""", SIDEBAR_SET,
    dict(
        label=_("Question title tips"),
        help_text=
        _("Tips visible on the ask or edit questions page about the question title."
          ),
        required=False,
        widget=Textarea(attrs={'rows': '10'})))

QUESTION_TAG_TIPS = Setting(
    'QUESTION_TAG_TIPS', u"""
 - Tags are words that will tell others what this question is about.
 - They will help other find your question.
 - A question can have up to |FORM_MAX_NUMBER_OF_TAGS| tags, but it must have at least |FORM_MIN_NUMBER_OF_TAGS|.
""", SIDEBAR_SET,
    dict(
        label=_("Tagging tips"),
        help_text=_(
            "Tips visible on the ask or edit questions page about good tagging."
        ),
        required=False,
        widget=Textarea(attrs={'rows': '10'})))
class BasePleaForm(SplitStageForm):
    """Base form for pleas"""

    split_form_options = {"trigger": "guilty", "nojs_only": True}

    guilty_extra = forms.CharField(
        label=_("Mitigation"),
        widget=Textarea(attrs={
            "class": "form-control",
            "rows": "4"
        }),
        help_text=_(
            "Is there something you would like the court to consider?"),
        required=False,
        max_length=5000)

    not_guilty_extra = forms.CharField(
        label=_("Not guilty because?"),
        widget=Textarea(attrs={
            "class": "form-control",
            "rows": "4"
        }),
        help_text=_("Why do you believe you are not guilty?"),
        max_length=5000,
        error_messages={"required": ERROR_MESSAGES["NOT_GUILTY_REQUIRED"]})

    interpreter_needed = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Oes/Nac oes"],
        coerce=to_bool,
        label=_("Do you need an interpreter in court?"),
        error_messages={
            "required": ERROR_MESSAGES["INTERPRETER_NEEDED_REQUIRED"]
        })

    interpreter_language = forms.CharField(
        widget=forms.TextInput(attrs={"class": "form-control"}),
        max_length=100,
        required=True,
        label="",
        help_text=_("If yes, tell us which language (include sign language):"),
        error_messages={
            "required": ERROR_MESSAGES["INTERPRETER_LANGUAGE_REQUIRED"]
        })

    interpreter_needed_guilty_court = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Oes/Nac oes"],
        coerce=to_bool,
        label=_("Do you need an interpreter in court?"),
        error_messages={
            "required": ERROR_MESSAGES["INTERPRETER_NEEDED_REQUIRED"]
        })

    interpreter_language_guilty_court = forms.CharField(
        widget=forms.TextInput(attrs={"class": "form-control"}),
        max_length=100,
        required=True,
        label="",
        help_text=_("If yes, tell us which language (include sign language):"),
        error_messages={
            "required": ERROR_MESSAGES["INTERPRETER_LANGUAGE_REQUIRED"]
        })

    hearing_language = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Saesneg/Cymraeg"],
        coerce=to_bool,
        label=_("If there is a hearing, which language do you wish to speak?"),
        error_messages={
            "required": ERROR_MESSAGES["HEARING_LANGUAGE_REQUIRED"]
        })

    documentation_language = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Saesneg/Cymraeg"],
        coerce=to_bool,
        label=
        _("Please state in which language you wish to receive any further documentation?"
          ),
        error_messages={
            "required": ERROR_MESSAGES["DOCUMENTATION_LANGUAGE_REQUIRED"]
        })

    disagree_with_evidence = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Ydw/Nac ydw"],
        coerce=to_bool,
        label=_(
            "Do you disagree with any evidence from a witness statement in "
            "the notice we sent to you?"),
        error_messages={
            "required": ERROR_MESSAGES["DISAGREE_WITH_EVIDENCE_REQUIRED"]
        })

    disagree_with_evidence_details = forms.CharField(
        label="",
        widget=Textarea(attrs={
            "class": "form-control",
            "rows": "3"
        }),
        help_text=_(
            "If yes, tell us the name of the witness (on the top left of the "
            "statement) and what you disagree with:"),
        max_length=5000,
        error_messages={
            "required":
            ERROR_MESSAGES["DISAGREE_WITH_EVIDENCE_DETAILS_REQUIRED"]
        })

    witness_needed = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Hoffwn/Na hoffwn"],
        coerce=to_bool,
        label=_("Do you want to call a defence witness?"),
        help_text=_(
            "Someone who can give evidence in court supporting your case."),
        error_messages={"required": ERROR_MESSAGES["WITNESS_NEEDED_REQUIRED"]})

    witness_details = forms.CharField(
        label="",
        widget=Textarea(attrs={
            "class": "form-control",
            "rows": "3"
        }),
        help_text=_(
            "If yes, tell us the name, address and date of birth of any "
            "witnesses you want to call  to support your case:"),
        max_length=5000,
        error_messages={
            "required": ERROR_MESSAGES["WITNESS_DETAILS_REQUIRED"]
        })

    witness_interpreter_needed = forms.TypedChoiceField(
        widget=DSRadioSelect,
        required=True,
        choices=YESNO_CHOICES["Oes/Nac oes"],
        coerce=to_bool,
        label=_("Does your witness need an interpreter in court?"),
        error_messages={
            "required": ERROR_MESSAGES["WITNESS_INTERPRETER_NEEDED_REQUIRED"]
        })

    witness_interpreter_language = forms.CharField(
        widget=forms.TextInput(attrs={"class": "form-control"}),
        max_length=100,
        required=True,
        label="",
        help_text=_("If yes, tell us which language (include sign language):"),
        error_messages={
            "required": ERROR_MESSAGES["WITNESS_INTERPRETER_LANGUAGE_REQUIRED"]
        })

    def __init__(self, *args, **kwargs):
        welsh_questions = kwargs.pop("welsh_questions", False)
        super(BasePleaForm, self).__init__(*args, **kwargs)

        if not welsh_questions:
            del self.fields["hearing_language"]
            del self.fields["documentation_language"]
Example #16
0
class AdministrationForm(forms.Form):
    arguments = forms.CharField(required=False,
                                widget=Textarea(attrs=settings.TEXTAREA_ATTRS))
Example #17
0
class ExportTemplateForm(Form):
    template = CharField(required=False,
                         widget=Textarea(attrs={
                             "class": "form-control",
                         }))
Example #18
0
 class Meta:
     model = Expense
     fields = ("description", "lead", "chargeable", "amount", "category", "receipt", "expense_date", "corporate_card", "comment")
     widgets = {"description": TextInput(attrs={"size": 40}),  # Increase default size
                "comment": Textarea(attrs={'cols': 17, 'rows': 2}),  # Reduce height and increase width
                "lead": CurrentLeadChoices}
Example #19
0
For example, if you ask an interesting question or give a helpful answer, your input will be upvoted. On the other hand if the answer is misleading, it will be downvoted. Each vote in favor will generate |REP_GAIN_BY_UPVOTED| points, each vote against will subtract |REP_LOST_BY_DOWNVOTED| points. There is a limit of 200 points that can be accumulated per question or answer. The table below explains karma requirements for each type of moderation task.

* add comments ->  |REP_TO_COMMENT|
* delete comments -> |REP_TO_DELETE_COMMENTS|
* close own questions -> |REP_TO_CLOSE_OWN|
* reopen own questions -> |REP_TO_REOPEN_OWN|
* retag questions -> |REP_TO_RETAG|
* edit any answer -> |REP_TO_EDIT_OTHERS|
* open any closed question -> |REP_TO_CLOSE_OTHERS|
* delete any comment -> |REP_TO_DELETE_COMMENTS|

**What is a gravatar?**

Gravatar means globally recognized avatar - your unique avatar image associated with your email address. It's simply a picture that shows next to your posts on the websites that support gravatar protocol. The default gravatar appears as a square filled with a snowflake-like figure. You can set your image at gravatar.com

**To participate in this community, do I need to create new account?**

No, you don't have to. You can login through any service that supports OpenID, e.g. Google, Yahoo, AOL, etc. [Login now!](/account/signin/ "Login")

**Why can other people can edit my questions/answers?**

Allowing experienced members of this community to curate the questions and answers improves the overall quality of the knowledge base content. If this approach is not for you, we respect your choice.

**Still have questions?**

Please ask your question, help make our community better!
""", FAQ_SET,
    dict(label="FAQ page text",
         help_text=" The faq page. ",
         widget=Textarea(attrs={'rows': '25'})))
Example #20
0
class MoneyIOForm(forms.Form):
    user = None
    account = forms.ChoiceField(choices=[],
                                label=ugettext('Account'),
                                required=True)
    happentime = forms.DateField(initial=datetime.date.today,
                                 label=ugettext('Happen Date'),
                                 required=True)
    moneyiotype = forms.ChoiceField(
        choices=[],
        label=ugettext('Money Income and Expense Type'),
        required=True)
    money = forms.FloatField(initial=0.0,
                             label=ugettext('Amount'),
                             required=True)
    currency = forms.ChoiceField(choices=[],
                                 label=ugettext('Currency'),
                                 required=True)
    isshare = forms.BooleanField(initial=False,
                                 label=ugettext('Is Share'),
                                 required=False)
    description = forms.CharField(max_length=500,
                                  widget=Textarea(),
                                  label=ugettext('Description'),
                                  required=False)
    '''The user'''
    def __init__(self, user, *args, **kwargs):
        super(MoneyIOForm, self).__init__(*args, **kwargs)
        self.user = user
        self.fields['account'].choices = AccountService().getAccountChoices(
            self.user)
        self.fields['moneyiotype'].choices = MoneyService(
        ).getMoneyIOUserTypeChoices(self.user)
        self.fields['currency'].choices = AccountService().getCurrencyChoices()
        if 'data' in kwargs:
            self.data = kwargs['data']

    def clean_money(self):
        cleaned_data = self.cleaned_data

        money = cleaned_data.get('money')
        if money <= 0:
            raise forms.ValidationError(
                ugettext('The amount should be more than zero'))

        return money

    def clean(self):
        cleaned_data = self.cleaned_data

        money = cleaned_data.get('money')
        moneyiotype_id = cleaned_data.get('moneyiotype')
        moneyiotype = MoneyService().getMoneyIOUserType(
            moneyiotype_id, self.user)
        isio = moneyiotype.isio
        account_id = cleaned_data.get('account')
        account = AccountService().getAccount(account_id, self.user)
        if account and account.type.canadvance == False and money > 0 and isio == -1 and account.totalmoney < money:
            totalmoney = account.totalmoney
            raise forms.ValidationError(
                ugettext(
                    'The account total amount (%(totalmoney)10.2f) is not enough to expense'
                ) % {'totalmoney': totalmoney})

        return cleaned_data
Example #21
0
 def __init__(self, question, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields["answers"] = forms.CharField(widget=Textarea(
         attrs={"style": "width:100%"}))
Example #22
0
class MoneyTransferForm(forms.Form):
    user = None
    happentime = forms.DateField(initial=datetime.date.today,
                                 label=ugettext('Happen Date'),
                                 required=True)
    fromaccount = forms.ChoiceField(choices=[],
                                    label=ugettext('From Account'),
                                    required=True)
    toaccount = forms.ChoiceField(choices=[],
                                  label=ugettext('To Account'),
                                  required=True)
    money = forms.FloatField(initial=0.0,
                             label=ugettext('Amount'),
                             required=True)
    currency = forms.ChoiceField(choices=[],
                                 label=ugettext('Currency'),
                                 required=True)
    description = forms.CharField(max_length=500,
                                  widget=Textarea(),
                                  label=ugettext('Description'),
                                  required=False)

    def __init__(self, user, *args, **kwargs):
        super(MoneyTransferForm, self).__init__(*args, **kwargs)
        self.user = user
        self.fields['fromaccount'].choices = AccountService(
        ).getAccountChoices(self.user)
        self.fields['toaccount'].choices = AccountService().getAccountChoices(
            self.user)
        self.fields['currency'].choices = AccountService().getCurrencyChoices()
        if 'data' in kwargs:
            self.data = kwargs['data']

    def clean(self):
        cleaned_data = self.cleaned_data

        fromaccount_id = cleaned_data.get('fromaccount')
        toaccount_id = cleaned_data.get('toaccount')
        if fromaccount_id == toaccount_id:
            raise forms.ValidationError(
                ugettext('The from account should not be same as to account'))

        cleaned_data = self.cleaned_data
        fromaccount_id = cleaned_data.get('fromaccount')
        money = cleaned_data.get('money')
        fromaccount = AccountService().getAccount(fromaccount_id, self.user)
        if fromaccount and fromaccount.type.canadvance == False and money > 0 and fromaccount.totalmoney < money:
            totalmoney = fromaccount.totalmoney
            raise forms.ValidationError(
                ugettext(
                    'The from account total amount (%(totalmoney)10.2f) is not enough to transfer'
                ) % {'totalmoney': totalmoney})

        return cleaned_data

    def clean_money(self):
        cleaned_data = self.cleaned_data

        money = cleaned_data.get('money')
        if money <= 0:
            raise forms.ValidationError(
                ugettext('The amount should be more than zero'))

        return money
Example #23
0
 class Meta:
     model = WorkshopParticipant
     fields = ['qualification_result', 'comment']
     widgets = {'comment': Textarea(attrs={'rows': 4})}
Example #24
0
 class Meta:
     model = Comment
     fields = ("text", )
     labels = {"text": "Текст комментария"}
     help_texts = {"text": "Введите текст Вашего комментария."}
     widgets = {"text": Textarea()}
Example #25
0
 def __init__(self, *args, **kwargs):
     super(Archive.ComponentForm, self).__init__(*args, **kwargs)
     self.fields['description'].widget = Textarea(attrs={
         'cols': 50,
         'rows': 5
     })
Example #26
0
class CreateProjectForm(forms.Form):
    error_css_class = 'error'
    required_css_class = 'required'

    task_type = SelectProjectType(TASK_TYPE, help_text=help_select_task_type)

    name = forms.CharField(required=True,
                           label="Project name",
                           max_length=200,
                           help_text=help_for_name,
                           widget=TextInput(attrs={"size": 60}))

    short_name = forms.CharField(required=True,
                                 label="Short project name",
                                 max_length=100,
                                 help_text=help_for_short_name,
                                 widget=TextInput(attrs={"size": 30}))

    description = forms.CharField(required=True,
                                  label="Description",
                                  max_length=8000,
                                  help_text=help_for_desc,
                                  widget=Textarea(attrs={
                                      "rows": 3,
                                      "cols": 60
                                  }))

    topics = SelectTopicsField(
        Topic.objects.filter(parent=None).order_by("name"),
        help_text=help_select_topics,
        widget=SelectMultiple(attrs={"size": 11}))

    starting_article_id = forms.IntegerField(min_value=0)
    ending_article_id = forms.IntegerField(min_value=0)

    contributor_id = SelectContributorId(
        Contributor.objects.order_by("id").all(),
        label="Contributor",
        help_text=help_select_contributors)

    # TODO: show min tokens only after Quiz is selected
    min_tokens_per_highlight = forms.IntegerField(min_value=0)
    max_tokens_per_highlight = forms.IntegerField(min_value=0)

    pybossa_url = forms.CharField(required=True,
                                  label="Pybossa server URL",
                                  initial="http://pybossa",
                                  max_length=1000,
                                  help_text=help_for_pybossa_url,
                                  widget=TextInput(attrs={"size": 60}))

    pybossa_api_key = forms.CharField(required=True,
                                      label="Pybossa API key",
                                      max_length=36,
                                      help_text=help_for_api_key,
                                      widget=TextInput(attrs={"size": 36}))

    debug_presenter = forms.BooleanField(required=False,
                                         initial=False,
                                         widget=HiddenInput)

    debug_server = forms.CharField(required=False,
                                   max_length=200,
                                   initial=settings.WEBPACK_DEV_SERVER,
                                   widget=HiddenInput)