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
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
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})
def url(self): """The API URL for this package.""" return models.url(controller='api.packages', action='show', id=self.name)
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))
def url(self): """The API URL for this package.""" return models.url( controller='api.packages', action='show', id=self.name)
from models import url, error allpatterns = [ url('views.index', ['/']), url('views.helps_index', ['/helps/', '/helps/<id>/']), error('views.handler404', [404]), error('views.handler500', [500]), ]