Esempio n. 1
0
    def as_dict(self, full=False):
        """Returns the dictionary representation of this package version.

        This is used to represent the package in API responses. Normally this
        just includes URLs and the pubspec, but if full is True, it will include
        all available information about the package version.
        """

        value = {
            'version': str(self.version),
            'url': self.url,
            'package_url': models.url(controller='api.packages',
                                      action='show',
                                      id=self.package.name),
            'new_dartdoc_url': self.url + '/new_dartdoc',
            'archive_url': models.url(controller='versions',
                                      action='show',
                                      package_id=self.package.name,
                                      id=str(self.version),
                                      format='tar.gz'),
            'pubspec': self.pubspec
        }

        if full:
            value.update({
                'created': self.created.isoformat(),
                'downloads': self.downloads,
                'libraries': self.libraries,
                'uploader': self.uploader.email()
            })

        return value
Esempio n. 2
0
    def as_dict(self, full=False):
        """Returns the dictionary representation of this package version.

        This is used to represent the package in API responses. Normally this
        just includes URLs and the pubspec, but if full is True, it will include
        all available information about the package version.
        """

        value = {
            "version": str(self.version),
            "url": self.url,
            "package_url": models.url(controller="api.packages", action="show", id=self.package.name),
            "new_dartdoc_url": self.url + "/new_dartdoc",
            "archive_url": models.url(
                controller="versions",
                action="show",
                package_id=self.package.name,
                id=str(self.version),
                format="tar.gz",
            ),
            "pubspec": self.pubspec,
        }

        if full:
            value.update(
                {
                    "created": self.created.isoformat(),
                    "downloads": self.downloads,
                    "libraries": self.libraries,
                    "uploader": self.uploaderEmail,
                }
            )

        return value
Esempio n. 3
0
    def as_dict(self, full=False):
        """Returns the dictionary representation of this package version.

        This is used to represent the package in API responses. Normally this
        just includes URLs and the pubspec, but if full is True, it will include
        all available information about the package version.
        """

        value = {
            'version': str(self.version),
            'url': self.url,
            'package_url': models.url(controller='api.packages',
                                      action='show',
                                      id=self.package.name),
            'new_dartdoc_url': self.url + '/new_dartdoc',
            'archive_url': models.url(controller='versions',
                                      action='show',
                                      package_id=self.package.name,
                                      id=str(self.version),
                                      format='tar.gz'),
            'pubspec': self.pubspec
        }

        if full:
            value.update({
                'created': self.created.isoformat(),
                'downloads': self.downloads,
                'libraries': self.libraries,
                'uploader': self.uploader.email()
            })

        return value
Esempio n. 4
0
def shorten(request):
    if request.method == "POST":
        form = urlform(request.POST)
        if form.is_valid() == True:
            link = form.cleaned_data.get("link")
            p = url(link)
            short = shortened(link)
            p.save()
            return render(request, "user_submit.html", {"link": link, "short": short})
        return HttpResponse("Invalid submission. Check one or more fields.")
    elif request.method == "GET":
        form = urlform()
        return render(request, "user_form.html", {"form": form})
Esempio n. 5
0
 def url(self):
     """The API URL for this package."""
     return models.url(controller='api.packages',
                       action='show',
                       id=self.name)
Esempio n. 6
0
 def url(self):
     """The API URL for this package version."""
     return models.url(controller='api.versions',
                       action='show',
                       package_id=self.package.name,
                       id=str(self.version))
Esempio n. 7
0
 def url(self):
     """The API URL for this package."""
     return models.url(
         controller='api.packages', action='show', id=self.name)
Esempio n. 8
0
 def url(self):
     """The API URL for this package version."""
     return models.url(controller='api.versions',
                       action='show',
                       package_id=self.package.name,
                       id=str(self.version))
Esempio n. 9
0
from models import url, error
allpatterns = [
    url('views.index', ['/']),
    url('views.helps_index', ['/helps/', '/helps/<id>/']),
    error('views.handler404', [404]),
    error('views.handler500', [500]),
]