Example #1
0
 def save(self, *args, **kwargs):
     if self.interlinear.strip():
         self.il_xhtml = make_html_interlinear(escape(self.interlinear), format=self.il_format)
     # Denormalization
     if not self.relay and self.ring:
         self.relay = self.ring.relay
     if not self.ring and self.relay:
         rings = self.relay.rings.all()
         num_rings = rings.count()
         if num_rings in (0, 1):
             # Probably a one-ring relay...
             self.ring, created = Ring.objects.get_or_create(relay=self.relay)
         else:
             # Just pick one
             self.ring = self.relay.rings.all()[0]
     super(Torch, self).save(*args, **kwargs)
Example #2
0
 def get_interlinear(self):
     return make_html_interlinear(self.interlinear, self.il_format, _escape)
Example #3
0
 def test_simple(self):
     raw = 'a b c'
     result = interlinears.make_html_interlinear(raw, format='monospace')
     self.assertEqual("<pre>%s</pre>" % raw, result)
Example #4
0
 def test_unsanitized(self):
     raw = 'a<b'
     with self.assertRaises(ValueError) as error:
         result = interlinears.make_html_interlinear(raw, format='monospace')
         self.assertEqual(error.exception, 'Input has not been sanitized')
Example #5
0
 def test_empty(self):
     raw = ''
     result = interlinears.make_html_interlinear(raw, format='monospace')
     self.assertEqual(raw, result)