예제 #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]),
]