コード例 #1
0
ファイル: series.py プロジェクト: DrDos0016/museum-of-zzt
    def list_block_context(self, *args, **kwargs):
        context = dict(
            pk=self.pk,
            model=self.model_name,
            url=self.url,
            cells=[
                {"datum": "link", "url": self.url(), "value": self.title, "tag": "td"},
                {"datum": "text", "value": self.last_entry_date, "tag": "td"},
                {"datum": "text", "value": epoch_to_unknown(self.first_entry_date), "tag": "td"},
                {"datum": "text", "value": self.article_set.count(), "tag": "td"},
            ],
        )

        return context
コード例 #2
0
 def list_block_context(self, extras=None, *args, **kwargs):
     context = dict(
         pk=self.pk,
         model=self.model_name,
         url=self.url,
         cells=[
             {"datum": "link", "url":self.url(), "value":self.title if self.title else "Untitled", "tag":"td"},
             {"datum": "link", "url":self.zfile.url(), "value":self.zfile.title, "tag":"td"},
             {"datum": "text", "value":self.author_link(), "tag":"td"},
             {"datum": "text", "value":epoch_to_unknown(self.date), "tag":"td"},
             {"datum": "text", "value":("—" if self.rating < 0 else self.rating), "tag":"td"}
         ],
     )
     return context
コード例 #3
0
ファイル: series.py プロジェクト: DrDos0016/museum-of-zzt
    def detailed_block_context(self, *args, **kwargs):
        """ Return info to populate a detail block """
        context = dict(
            pk=self.pk,
            model=self.model_name,
            preview=dict(url=self.preview_url, alt=self.preview_url),
            url=self.url,
            title={"datum": "title", "value": self.title, "url": self.url},
            columns=[],
        )

        context["columns"].append([
            {"datum": "text", "label": "Newest Entry", "value": self.last_entry_date},
            {"datum": "text", "label": "Oldest Entry", "value": epoch_to_unknown(self.first_entry_date)},
            {"datum": "text", "label": "Articles", "value": self.article_set.count()},
            {"datum": "text", "value": mark_safe("<p>{}</p>".format(self.description))},
        ])

        return context
コード例 #4
0
    def detailed_block_context(self, extras=None, *args, **kwargs):
        context = dict(
            pk=self.pk,
            model=self.model_name,
            preview=dict(url=self.preview_url, alt=self.preview_url),
            url=self.url,
            title={"datum": "title", "value":mark_safe(self.title if self.title else "<i>Untitled Review</i>"), "url":self.url()},
            columns=[],
        )

        context["columns"].append([
            {"datum": "link", "label": "File", "value": self.zfile.title, "url": self.zfile.url()},
            {"datum": "text", "label": "Reviewer", "value": self.author_link()},
            {"datum": "text", "label": "Date", "value": epoch_to_unknown(self.date)},
        ])

        if self.rating >= 0:
            context["columns"][0].append(
                {"datum": "text", "label": "Rating", "value": "{} / 5.0".format(self.rating)},
            )

        return context
コード例 #5
0
ファイル: article.py プロジェクト: DrDos0016/museum-of-zzt
    def detailed_block_context(self, extras=None, *args, **kwargs):
        """ Return info to populate a detail block """
        context = self.initial_context(*args, **kwargs)
        context["title"] = {"datum": "title", "value":self.title, "url":self.url(), "icons":self.get_all_icons()}
        context["columns"] = []

        # Adjust CSS for unpublished articles
        if self.published == self.UPCOMING:
            context["title"]["roles"] = [
                "restricted", "article-upcoming"
            ]
        elif self.published == self.UNPUBLISHED:
            context["title"]["roles"] = [
                "restricted", "article-unpublished"
            ]

        # Unlock articles for patrons
        context = self.unlock_check(context)

        context["columns"].append([
            {"datum": "text", "label": "Author", "value":self.author},
            {"datum": "text", "label": "Date", "value":epoch_to_unknown(self.publish_date)},
            {"datum": "text", "label": "Category", "value":self.category},
        ])

        if self.file_set.exists():
            context["columns"][0].append(
            {"datum": "multi-link", "label": "Associated Files", "values":self.get_zfile_links()}
        )

        context["columns"][0].append({"datum": "text", "label": "Description", "value":self.description})

        if self.series.count():
            context["columns"][0].append(
                {"datum": "multi-link", "label":"Series", "values":self.get_series_links()}
            )

        return context
コード例 #6
0
ファイル: article.py プロジェクト: DrDos0016/museum-of-zzt
    def list_block_context(self, extras=None, *args, **kwargs):
        context = self.initial_context(*args, **kwargs)
        context.update(
            pk=self.pk,
            model=self.model_name,
            hash_id="article-{}".format(self.pk),
            url=self.url,
            cells=[
                {"datum": "title", "value":self.title, "url":self.url(), "icons":self.get_all_icons(), "tag": "td"},
                {"datum": "text", "value": self.author, "tag":"td"},
                {"datum": "text", "value": epoch_to_unknown(self.publish_date), "tag":"td"},
                {"datum": "text", "value": self.category, "tag":"td"},
                {"datum": "text", "value": self.description, "tag":"td"},
            ],
        )

        if self.is_restricted:
            context["cells"][0]["roles"] = ["restricted"]

        # Unlock articles for patrons
        context = self.unlock_check(context, view="list")

        return context