Ejemplo n.º 1
0
    def get(self, request):
        if 'package_name' not in self.request.GET:
            raise Http404
        package_name = self.request.GET.get('package_name')

        package = get_web_package(package_name)
        if package is not None:
            return redirect(package)
        else:
            return render(request, 'core/package_search.html', {
                'package_name': package_name
            })
Ejemplo n.º 2
0
def package_page(request, package_name):
    """
    Renders the package page.
    """
    package = get_web_package(package_name)
    if not package:
        raise Http404
    if package.get_absolute_url() != request.path:
        return redirect(package)

    is_subscribed = False
    if request.user.is_authenticated():
        # Check if the user is subscribed to the package
        is_subscribed = request.user.is_subscribed_to(package)

    return render(request, 'core/package.html', {
        'package': package,
        'panels': get_panels_for_package(package),
        'is_subscribed': is_subscribed,
    })
Ejemplo n.º 3
0
    def get_object(self, request, package_name):
        package = get_web_package(package_name)
        if package is None:
            raise Http404

        return package