示例#1
0
class Strip(models.Model):
    comic = models.ForeignKey("rack.Comic")
    url = models.URLField()
    added_at = models.DateTimeField(default=_utc_now)

    objects = StripManager()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        module_path = 'rack.quirks.%s' % (self.comic.dosage_name.lower(),)
        try:
            module = importlib.import_module(module_path)
        except ImportError:
            # if no specific quirk module, load the dummy quirk class.
            from rack.quirks import BaseQuirk
            self.quirk = BaseQuirk()
            self.template = 'generic'
        else:
            quirk_class_name = self.comic.dosage_name.lower()
            self.quirk = getattr(module, quirk_class_name)
            self.template = self.comic.dosage_name.lower()

    def __str__(self):
        return "%s strip for %s" % (self.comic.name, self.added_at)

    def save_extra_data(self, json):
        self.quirk.save_extra_strip_data(self.comic, self, json)
示例#2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        module_path = 'rack.quirks.%s' % (self.comic.dosage_name.lower(),)
        try:
            module = importlib.import_module(module_path)
        except ImportError:
            # if no specific quirk module, load the dummy quirk class.
            from rack.quirks import BaseQuirk
            self.quirk = BaseQuirk()
            self.template = 'generic'
        else:
            quirk_class_name = self.comic.dosage_name.lower()
            self.quirk = getattr(module, quirk_class_name)
            self.template = self.comic.dosage_name.lower()