Ejemplo n.º 1
0
 def numbered_title(self):
     """ Return a formatted title using the number for this work, such as "Act 5 of 2009".
     This usually differs from the short title. May return None.
     """
     plugin = plugins.for_work('work-detail', self)
     if plugin:
         return plugin.work_numbered_title(self)
Ejemplo n.º 2
0
    def get_publication_document(self, params, work, user):
        finder = plugins.for_work('publications', work)

        if finder:
            try:
                publications = finder.find_publications(params)

                if len(publications) == 1:
                    pub_doc_details = publications[0]
                    self.stdout.write(
                        self.style.NOTICE(
                            "Linking publication document {} to {}".format(
                                pub_doc_details.get('url'), work)))

                    pub_doc = PublicationDocument()
                    pub_doc.work = work
                    pub_doc.file = None
                    pub_doc.trusted_url = pub_doc_details.get('url')
                    pub_doc.size = pub_doc_details.get('size')
                    if not self.dry_run:
                        pub_doc.save()

                else:
                    self.pub_doc_task(work, user)

            except ValueError as e:
                raise ValidationError({'message': str(e)})

        else:
            self.pub_doc_task(work, user)
Ejemplo n.º 3
0
 def friendly_type(self):
     """ Return a friendly document type for this work, such as "Act" or "By-law".
     """
     plugin = plugins.for_work('work-detail', self)
     if plugin:
         return plugin.work_friendly_type(self)