def solution(ctx, text): """A solution to a problem. The intent is for the solution to be hidden by default, and only shown after an explicit action by the reader. The explicit action can be: - Clicking a dumb link, which takes the reader to a special page that shows only the solution - Clicking a button, which shows the solution using Javascript To set up the special page, this filter needs special setup in the view. So, it can only be used within lesson pages. """ solutions = ctx['$solutions'] solution_index = len(solutions) solution_url = ctx['lesson_url'](lesson=ctx['lesson'].slug, page=ctx['page'].slug, solution=solution_index) solution = markdown_util.convert_markdown(text) solutions.append(solution) t = Markup(textwrap.dedent(""" <div class="solution" id="solution-{}"> <h3>Řešení</h3> <div class="solution-cover"> <a href="{}"><span class="link-text">Ukázat řešení</span></a> </div> <div class="solution-body" aria-hidden="true"> {} </div> </div> """)) return t.format(solution_index, solution_url, solution)
def __unicode__(self): word_history_cls = globals()['Word'].__history_mapper__.class_ word_1 = word_history_cls.query.filter_by(id=self.word_id_1) word_2 = word_history_cls.query.filter_by(id=self.word_id_2) word_1 = word_1.filter( word_history_cls.created<self.created+datetime.timedelta(seconds=60) ).order_by('word_history.created DESC').first() language_1 = Language.query.filter_by(id=word_1.language_id).first() word_2 = word_2.filter( word_history_cls.created<self.created+datetime.timedelta(seconds=60) ).order_by('word_history.created DESC').first() language_2 = Language.query.filter_by(id=word_2.language_id).first() # I don't expect the part ID to change relation = Relation.query.filter_by(id=self.relation_id).first() markup = Markup( u'<a href="{0}">{1}</a> <em>{2} of</em> <a href="{3}">{4}</a>' ) markup = markup.format( url_for('words.view', word_data=word_1.word, language_code=language_1.code), word_1.word, relation.part.label.lower(), url_for('words.view', word_data=word_2.word, language_code=language_2.code), word_2.word ) return markup
def __unicode__(self): word_history_cls = globals()['Word'].__history_mapper__.class_ part = Part.query.filter_by(id=self.part_id).first() word = word_history_cls.query.filter(word_history_cls.id==self.word_id)\ .filter(word_history_cls.version==self.version).first() language = Language.query.filter(Language.id==self.language_id).first() markup = Markup(u'Added {0} to <a href="{1}">{2}</a> for translations') markup = markup.format(language.label, url_for( 'words.view', word_data=word.word, language_code=language.code), word.word) return markup
def __unicode__(self): part = Part.query.filter_by(id=self.part_id).first() markup = Markup(u'{0} <em>relationship</em>') return markup.format(part.label)