def chart(request, **kwargs): from django.views.static import serve chart = kwargs['chart'] if 'chart' in kwargs else None if 'maintainer_id' in kwargs or 'maintainer_email' in kwargs: kwargs['maintainer'] = get_maintainer_or_404( kwargs.get('maintainer_id'), kwargs.get('maintainer_email')) if 'herd' in kwargs: kwargs['herd'] = get_object_or_404(Herd, herd=kwargs['herd']) for kw in ('-small', '-weekly', '-monthly', '-yearly'): if chart.endswith(kw): if kw in ('-weekly', '-monthly', '-yearly'): kwargs['period'] = kw kwargs[kw] = True chart = chart[:-len(kw)] if chart == 'pie-packages': path = charts.pie_packages(**kwargs) elif chart == 'pie-versions': path = charts.pie_versions(**kwargs) elif chart == 'packages': path = charts.packages(**kwargs) elif chart == 'versions': path = charts.versions(**kwargs) else: return HttpResponseNotFound() return serve(request, path, document_root=charts.CHARTS_ROOT)
def chart(request, **kwargs): from django.views.static import serve chart = kwargs['chart'] if 'chart' in kwargs else None if 'maintainer_id' in kwargs or 'maintainer_email' in kwargs: kwargs['maintainer'] = get_maintainer_or_404( kwargs.get('maintainer_id'), kwargs.get('maintainer_email') ) if 'herd' in kwargs: kwargs['herd'] = get_object_or_404(Herd, herd=kwargs['herd']) for kw in ('-small', '-weekly', '-monthly', '-yearly'): if chart.endswith(kw): if kw in ('-weekly', '-monthly', '-yearly'): kwargs['period'] = kw kwargs[kw] = True chart = chart[:-len(kw)] if chart == 'pie-packages': path = charts.pie_packages(**kwargs) elif chart == 'pie-versions': path = charts.pie_versions(**kwargs) elif chart == 'packages': path = charts.packages(**kwargs) elif chart == 'versions': path = charts.versions(**kwargs) else: return HttpResponseNotFound() return serve(request, path, document_root=charts.CHARTS_ROOT)
def maintainer(request, maintainer_id=None, maintainer_email=None): maintainer = get_maintainer_or_404(maintainer_id, maintainer_email) packages = Package.objects.for_maintainer(maintainer, last_versions=True) try: last_scan = \ EuscanResult.objects.for_maintainer(maintainer).latest().datetime except EuscanResult.DoesNotExist: last_scan = None favourited = False if request.user.is_authenticated(): if maintainer in get_profile(request.user).maintainers.all(): favourited = True return {'maintainer': maintainer, 'packages': packages, 'last_scan': last_scan, 'favourited': favourited}
def maintainer(request, maintainer_id=None, maintainer_email=None): maintainer = get_maintainer_or_404(maintainer_id, maintainer_email) packages = Package.objects.for_maintainer(maintainer, last_versions=True) try: last_scan = \ EuscanResult.objects.for_maintainer(maintainer).latest().datetime except EuscanResult.DoesNotExist: last_scan = None favourited = False if request.user.is_authenticated(): if maintainer in get_profile(request.user).maintainers.all(): favourited = True return { 'maintainer': maintainer, 'packages': packages, 'last_scan': last_scan, 'favourited': favourited }
def unfavourite_maintainer(request, maintainer_id=None, maintainer_email=None): obj = get_maintainer_or_404(maintainer_id, maintainer_email) get_profile(request.user).maintainers.remove(obj) if "nojs" in request.POST: return redirect(reverse("maintainer", args=(obj.email, ))) return {"success": True}