Esempio n. 1
0
    def generate_accepted_news_content(self, package, version):
        """
        Generates the content for a news item created when a package version is
        first created.

        :type package: :class:`SourcePackageName
            <distro_tracker.core.models.SourcePackageName>`
        :type version: :class:`string`
        """
        package_version = package.source_package_versions.get(version=version)
        entry = package_version.repository_entries.all()[0]

        # Add dsc file
        content = get_resource_content(entry.dsc_file_url)
        if content:
            content = content.decode('utf-8')
        else:
            content = ''

        # Add changelog entries since last update...
        changelog_content = package_version.get_changelog_entry()
        if changelog_content:
            content = content + '\n<span id="changes">Changes:</span>\n'
            content = content + changelog_content

        return content
Esempio n. 2
0
    def generate_accepted_news_content(self, srcpkg):
        """
        Generates the content for a news item created when a package version is
        first created.

        :type srcpkg: :class:`~distro_tracker.core.models.SourcePackage`
        """
        entry = srcpkg.repository_entries.all()[0]

        # Add dsc file
        content = get_resource_content(entry.dsc_file_url)
        if content:
            content = content.decode('utf-8')
        else:
            content = ''

        # Add changelog entries since last update...
        changelog_content = srcpkg.get_changelog_entry()
        if changelog_content:
            content += '\n<span id="changes">Changes:</span>\n'
            content += changelog_content

        return content
Esempio n. 3
0
    def get_user_details(self, remote_user):
        """
        Gets the details of the given user from the Debian NM REST API.

        :return: Dict with the keys ``first_name``, ``last_name``
            ``None`` if the API lookup did not return anything.
        """
        if not remote_user.endswith('@debian.org'):
            # We only know how to extract data for DD via NM API
            return None

        content = get_resource_content(
            'https://nm.debian.org/api/people?' +
            urlencode({'uid': self.get_uid(remote_user)}))
        if content:
            result = json.loads(content.decode('utf-8'))['r']

        if not result:
            return None
        return {
            'first_name': result[0]['cn'],
            'last_name': result[0]['sn'],
        }