def get_context_data(self, **kwargs): context = super(MarkupView, self).get_context_data(**kwargs) markup = self.get_object() m = TextMarkup() m.from_json(markup.text) context['text'] = process_markup(m) context['poem'] = markup.poem context['poem'].name = markup.poem.get_name() context['lines_count'] = markup.poem.count_lines() context['additional'] = markup.get_automatic_additional() markups = set() for markup_instance in markup.poem.markups.all(): markups.add(markup_instance.markup_version) context['markups'] = list(markups) return context
def test_from_to(self): clean_markup = Markup() self.assertEqual(MARKUP_EXAMPLE, clean_markup.from_xml(MARKUP_EXAMPLE.to_xml())) clean_markup = Markup() self.assertEqual(MARKUP_EXAMPLE, clean_markup.from_json(MARKUP_EXAMPLE.to_json()))
def get_markup(self): markup = InternalMarkup() markup.from_json(self.text) return markup