Beispiel #1
0
    def __init__(
            self,
            name,
            placeholder=""):
        """ Construct a Autocomplete input set.

        Required:
        str     name                name of key to be submited as part of form

        Optional:
        str     autocomple_class    class representing which type of
                                    autocomplete
        str     placeholder         placeholder to put inside TextInput

        """
        super(AutocompleteInput, self).__init__()
        self.append_class(self.AUTOCOMPLETE_CLASS)

        # textinput doesn't actually contain data but does autocomplete.
        input_div = Div()  # for overflow auto and automatic width
        input = TextInput(name + "-" + self.AUTOCOMPLETE_LABEL_CLASS)
        input.set_placeholder(placeholder)
        input.append_class(self.AUTOCOMPLETE_LABEL_CLASS)
        input_div.append_child(input)
        self.append_child(input_div)

        # hiddeninput has actual data to submit.
        hidden = HiddenInput(name)
        hidden.append_class(self.AUTOCOMPLETE_VALUE_CLASS)
        self.append_child(hidden)
Beispiel #2
0
    def __init__(self, current_person, story_id):
        """ Construct a CommentForm.

        Required:
        Person  current_person  the current User's associated Person
        id  story_id    id of the SqNode Story object

        """
        super(CommentForm, self).__init__(
                "{}{}".format(PAGE_NAME.LEAGUE, story_id))

        # TODO: make this draw from view.url constants
        self.set_action("/comment")
        self.append_class(self.COMMENT_FORM_CLASS)

        self.append_child(HiddenInput(SQ_DATA.GAME_ID, story_id))

        self.append_child(AppThumbnail(current_person.picture_url))

        # div allows overflow: auto to maximize that column
        comment_div = Div()
        comment_input = TextInput(SQ_DATA.MESSAGE)
        comment_input.set_placeholder(Copy.comment)
        comment_div.append_child(comment_input)

        self.append_child(comment_div)
        self.append_child(SubmitButton(Copy.comment))
Beispiel #3
0
    def __init__(self, data):
        """ Construct a Create Game form element tree.

        Required:
        Model   data        model constants for data-* hidden inputs

        """
        super(CreateGameForm, self).__init__(PAGE_NAME.CREATE_GAME)

        # TODO: make this draw from view.url constants
        self.set_action("/create/game")

        # TODO: is there some mild abstraction needed here? or other info?
        # add some context to the form
        self.append_child(HiddenInput(SQ_DATA.LEAGUE_ID))

        # tag header
        headline_input = TextInput(SQ_DATA.MESSAGE)
        headline_input.set_maxlength(self.HEADLINE_LENGTH)
        headline_input.set_placeholder(Copy.headline)
        headline_input.append_class(self.HEADLINE_INPUT_CLASS)
        self.append_child(headline_input)

        # versus/with checkbox
        # TODO: optionally set is_on based on some stored model/session value.
        self.append_child(GameTypeSubheader())

        # the three tag groups: won,lost, played
        self.append_child(OpponentTagsGroup(
                SQ_VALUE.RIVALRY,
                SQ_VALUE.WON,
                self.MAX_TAGS,
                Copy.won))
        self.append_child(OpponentTagsGroup(
                SQ_VALUE.RIVALRY,
                SQ_VALUE.LOST,
                self.MAX_TAGS,
                Copy.lost))
        self.append_child(OpponentTagsGroup(
                SQ_VALUE.CAMARADERIE,
                SQ_VALUE.PLAYED,
                self.MAX_TAGS))

        # add a blank subheadline for the dotted-line separator
        self.append_child(Subheadline(""))

        # add a sport tag autocomplete
        self.append_child(SportTagSubheader())

        # add form submit and close buttons
        self.append_child(PostButtonSection())