def project_versions(request, project_slug): """ Shows the available versions and lets the user choose which ones he would like to have built. """ project = get_object_or_404(Project.objects.protected(request.user), slug=project_slug) versions = Version.objects.public(user=request.user, project=project, only_active=False) active_versions = versions.filter(active=True) inactive_versions = versions.filter(active=False) inactive_filter = VersionSlugFilter(request.GET, queryset=inactive_versions) active_filter = VersionSlugFilter(request.GET, queryset=active_versions) # If there's a wiped query string, check the string against the versions list and display a success message. # Deleting directories doesn't know how to fail. :) wiped = request.GET.get('wipe', '') wiped_version = versions.filter(slug=wiped) if wiped and wiped_version.count(): messages.success(request, 'Version wiped: ' + wiped) return render_to_response('projects/project_version_list.html', { 'inactive_filter': inactive_filter, 'active_filter': active_filter, 'project': project, }, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): context = super(ProjectDetailView, self).get_context_data(**kwargs) project = self.get_object() context['versions'] = Version.objects.public(user=self.request.user, project=project) context['filter'] = VersionSlugFilter(self.request.GET, queryset=context['versions']) protocol = 'http' if self.request.is_secure(): protocol = 'https' context['badge_url'] = "%s://%s%s?version=%s" % ( protocol, settings.PRODUCTION_DOMAIN, reverse('project_badge', args=[project.slug]), project.get_default_version(), ) context['site_url'] = "%s://%s%s?badge=%s" % ( protocol, settings.PRODUCTION_DOMAIN, reverse('projects_detail', args=[project.slug]), project.get_default_version(), ) return context
def project_detail(request, project_slug): """ A detail view for a project with various dataz """ queryset = Project.objects.protected(request.user) project = get_object_or_404(queryset, slug=project_slug) versions = project.versions.public(request.user, project) filter = VersionSlugFilter(request.GET, queryset=versions) if request.is_secure(): protocol = 'https' else: protocol = 'http' badge_url = "%s://%s%s?version=%s" % ( protocol, settings.PRODUCTION_DOMAIN, reverse('project_badge', args=[project.slug]), project.get_default_version(), ) site_url = "%s://%s%s?badge=%s" % ( protocol, settings.PRODUCTION_DOMAIN, reverse('projects_detail', args=[project.slug]), project.get_default_version(), ) return render_to_response( 'projects/project_detail.html', { 'project': project, 'versions': versions, 'filter': filter, 'badge_url': badge_url, 'site_url': site_url, }, context_instance=RequestContext(request), )
def project_versions(request, project_slug): """ Shows the available versions and lets the user choose which ones he would like to have built. """ project = get_object_or_404(Project.objects.protected(request.user), slug=project_slug) versions = Version.objects.public(user=request.user, project=project, only_active=False) active_versions = versions.filter(active=True) inactive_versions = versions.filter(active=False) inactive_filter = VersionSlugFilter(request.GET, queryset=inactive_versions) active_filter = VersionSlugFilter(request.GET, queryset=active_versions) return render_to_response('projects/project_version_list.html', { 'inactive_filter': inactive_filter, 'active_filter': active_filter, 'project': project, }, context_instance=RequestContext(request))
def project_detail(request, project_slug): """ A detail view for a project with various dataz """ queryset = Project.objects.protected(request.user) project = get_object_or_404(queryset, slug=project_slug) versions = project.versions.public(request.user, project) filter = VersionSlugFilter(request.GET, queryset=versions) return render_to_response( 'projects/project_detail.html', { 'project': project, 'versions': versions, 'filter': filter, }, context_instance=RequestContext(request), )
def version_filter_autocomplete(request, project_slug): queryset = Project.objects.public(request.user) project = get_object_or_404(queryset, slug=project_slug) versions = Version.objects.public(request.user) filter = VersionSlugFilter(request.GET, queryset=versions) format = request.GET.get('format', 'json') if format == 'json': names = filter.qs.values_list('slug', flat=True) json_response = json.dumps(list(names)) return HttpResponse(json_response, mimetype='text/javascript') elif format == 'html': return render_to_response( 'core/version_list.html', { 'project': project, 'versions': versions, 'filter': filter, }, context_instance=RequestContext(request), ) else: raise HttpResponse(status=400)