Esempio n. 1
0
    def __init__(self, tablename, fieldname, show_link=True, pdf=False):
        """
            Constructor

            @param show_link: show representation as clickable link
        """

        if not show_link:
            lookup = key = None
        else:
            lookup = tablename
            key = fieldname

        super(ShipmentCodeRepresent, self).__init__(
            lookup=lookup,
            key=key,
            show_link=show_link,
        )
        if not show_link:
            # Make lookup-function a simple echo
            self._lookup = lambda values, rows=None: \
                           {v: B(v if v else self.none) for v in values}

        c, f = tablename.split("_", 1)
        args = ["[id]"]
        if pdf:
            args.append("form")
        self.linkto = URL(c=c, f=f, args=args, extension="")
    def get_html(self):
        if self.stale_recommendations:
            self.card_title = "New problems to solve!"
            card_content = TAG[""](SPAN(
                "It has been more than a week since you last generated problem recommendations. Generate new ones and keep getting better by solving them."
            ))
            self.ctas = [
                dict(btn_url=URL("problems", "recommendations"),
                     btn_text="Generate recommendations",
                     btn_class="recommendations-card-generate-recommendations")
            ]
        else:
            self.card_title = "StopStalk can recommend now!"
            card_content = TAG[""](
                SPAN(
                    "StopStalk will recommend you problems based on your past submissions."
                ), " ", SPAN("Click on the"), " ", B("'Find me problems'"),
                " ",
                SPAN(
                    "button on the top and keep increasing your level gradually!"
                ))
            self.ctas = [
                dict(btn_url=URL("problems", "recommendations"),
                     btn_text="Find me problems",
                     btn_class="recommendations-card-find-me-problems")
            ]

        card_html = BaseCard.get_html(
            self,
            **dict(card_title=self.card_title,
                   card_content=card_content,
                   cta_links=self.get_cta_html(),
                   card_color_class="white",
                   card_text_color_class="black-text"))
        return card_html
Esempio n. 3
0
    def get_html(self):
        streak_value = self.get_data()
        if self.kind == "day":
            card_content = P("You're at a ", B("%d day streak" % streak_value),
                             ". Keep solving a new problem everyday!")
        elif self.kind == "accepted":
            card_content = P("You're at a ",
                             B("%d accepted problem streak" % streak_value),
                             ".", BR(), "Let the greens rain!")
        else:
            return "FAILURE"

        card_html = BaseCard.get_html(
            self,
            **dict(card_title=self.card_title,
                   card_content=card_content,
                   cta_links=self.get_cta_html(),
                   card_color_class="white",
                   card_text_color_class="black-text"))
        return card_html
Esempio n. 4
0
    def get_html(self):
        count = self.get_data()
        card_content = P(
            "You have ", B(current.T("%s %%{account}") % count),
            " linked with StopStalk. Update your profile with more handles to track your competitive programming progress."
        )

        card_html = BaseCard.get_html(
            self,
            **dict(card_title=self.card_title,
                   card_content=card_content,
                   cta_links=self.get_cta_html(),
                   card_color_class="white",
                   card_text_color_class="black-text"))
        return card_html
Esempio n. 5
0
    def get_html(self):
        data = self.get_data()

        self.ctas = [
            dict(btn_text="Show me",
                 btn_url=URL("default",
                             "search",
                             vars={"institute": data["institute"]}),
                 btn_class="add-more-friends-card-institute-search")
        ]

        card_content = P(
            "You have ", B(current.T("%s %%{friend}") % data["friend_count"]),
            " on StopStalk. For a better competitive programming learning experience, we recommend you to add more friends."
        )

        card_html = BaseCard.get_html(
            self,
            **dict(card_title=self.card_title,
                   card_content=card_content,
                   cta_links=self.get_cta_html(),
                   card_color_class="white",
                   card_text_color_class="black-text"))
        return card_html
Esempio n. 6
0
 def create_balance_table(self):
     table_keys = THEAD(TR(*[TD(B(k)) for k in self.balance_table_columns]))
     table_rows = [TR(*[TD(v) for k, v in row.items()])
                   for row in self.balance_per_category]
     balance_table = TABLE(table_keys, table_rows, _class='web2py_grid')
     return balance_table