示例#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
示例#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
示例#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
示例#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})
示例#5
0
 def url(self):
     """The API URL for this package."""
     return models.url(controller='api.packages',
                       action='show',
                       id=self.name)
示例#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))
示例#7
0
 def url(self):
     """The API URL for this package."""
     return models.url(
         controller='api.packages', action='show', id=self.name)
示例#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))
示例#9
0
文件: urls.py 项目: ii64/Flasknic
from models import url, error
allpatterns = [
    url('views.index', ['/']),
    url('views.helps_index', ['/helps/', '/helps/<id>/']),
    error('views.handler404', [404]),
    error('views.handler500', [500]),
]