diff --git a/apps/base/templates/admin.html b/apps/base/templates/admin.html index 42f8d5ca..c4530020 100644 --- a/apps/base/templates/admin.html +++ b/apps/base/templates/admin.html @@ -1,31 +1,66 @@ {% extends 'base.html' %} -{% block title %}Mozilla FlightDeck Admin Area{% endblock title %} +{% block title %}Mozilla FlightDeck Admin Area - {% endblock title %} {% block head_prejs %} {% endblock %} -{% block app_content %} -
-

Search

-{% if message %} -

{{message}}

-{% endif %} - {% csrf_token %} - -
+{% block head %} + + +{% endblock %} + +{% block app_content %} +
+

Crons

+ {% if message %} +

{{message}}

+ {% endif %} + {{ safe_csrf_token()|safe }} + +
+ + +
+

Package  

+ + +
+
{% endblock %} diff --git a/apps/base/templates/admin/_package_result.html b/apps/base/templates/admin/_package_result.html new file mode 100644 index 00000000..e729ffc2 --- /dev/null +++ b/apps/base/templates/admin/_package_result.html @@ -0,0 +1,21 @@ + +
+ + + +
diff --git a/apps/base/templates/monitor.html b/apps/base/templates/monitor.html index f3bb7771..9ac012a6 100644 --- a/apps/base/templates/monitor.html +++ b/apps/base/templates/monitor.html @@ -29,8 +29,8 @@

Free space

diff --git a/apps/base/urls.py b/apps/base/urls.py index b11cb79f..cf0751d7 100644 --- a/apps/base/urls.py +++ b/apps/base/urls.py @@ -8,4 +8,6 @@ urlpatterns = patterns('', url('^services/monitor$', 'base.views.monitor', name='monitor'), url('^services/settings$', 'base.views.site_settings', name='settings'), url('^services/admin$', 'base.views.admin', name='admin_triggers'), + url('^services/admin/package$', 'base.views.get_package', name='admin_get_package'), + url('^services/admin/package/update$', 'base.views.update_package', name='admin_update_package'), ) diff --git a/apps/base/views.py b/apps/base/views.py index 5fe93db4..b73e5c24 100644 --- a/apps/base/views.py +++ b/apps/base/views.py @@ -6,9 +6,10 @@ import commonware.log from django.conf import settings from django.contrib.auth.decorators import user_passes_test from django.http import HttpResponse -from django.shortcuts import render_to_response +from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext, loader from django.views.debug import get_safe_settings +from django.template.loader import get_template from elasticutils import get_es import base.tasks @@ -130,10 +131,10 @@ def monitor(request): s_path = '%s/' % settings.SDKDIR_PREFIX x = os.statvfs(x_path) s = os.statvfs(s_path) - data['free'] = { - 'xpi_targetdir %s' % x_path: (x.f_bavail * x.f_frsize) / 1024, - 'sdkdir_prefix %s' % s_path: (s.f_bavail * s.f_frsize) / 1024 - } + data['free'] = [ + ('xpi_targetdir %s' % x_path, x.f_bavail * x.f_frsize), + ('sdkdir_prefix %s' % s_path, s.f_bavail * s.f_frsize) + ] data['filepaths'] = filepath_results @@ -190,13 +191,31 @@ def monitor(request): # Check Redis # TODO: we don't currently use redis - context = RequestContext(request, data) status = 200 if status else 500 template = loader.get_template('monitor.html') return HttpResponse(template.render(context), status=status) +def get_package(request): + package = get_object_or_404(Package, pk=request.GET['package_id']) + return render_to_response('admin/_package_result.html', { + 'package': package + }, context_instance=RequestContext(request)) + +@user_passes_test(lambda u: u.is_superuser) +def update_package(request): + package = get_object_or_404(Package, pk=request.POST['package_id']) + if 'featured' in request.POST: + package.featured = request.POST.get('featured') == 'true' + + if 'example' in request.POST: + package.example = request.POST.get('example') == 'true' + + package.save() + return HttpResponse({'status':'ok'}, content_type='text/javascript') + + def homepage(r): # one more for the main one addons_limit = settings.HOMEPAGE_PACKAGES_NUMBER @@ -216,6 +235,7 @@ def homepage(r): context_instance=RequestContext(r)) + def robots(request): data = "User-agent: *\n" if not settings.ENGAGE_ROBOTS: diff --git a/apps/jetpack/models.py b/apps/jetpack/models.py index b1774661..38e6f160 100644 --- a/apps/jetpack/models.py +++ b/apps/jetpack/models.py @@ -1496,6 +1496,10 @@ class Package(BaseModel, SearchMixin): active = models.BooleanField(default=True, blank=True) # deleted is the limbo state deleted = models.BooleanField(default=False, blank=True) + # is an example package + example = models.BooleanField(default=False, blank=True) + # is a featured package + featured = models.BooleanField(default=False, blank=True) #package activity score activity_rating = models.DecimalField(default=Decimal('0.0'), max_digits=4, decimal_places=3) diff --git a/apps/search/templates/_package_result.html b/apps/search/templates/_package_result.html index d74d8c5f..955f96b4 100644 --- a/apps/search/templates/_package_result.html +++ b/apps/search/templates/_package_result.html @@ -2,21 +2,26 @@

{{ package.full_name }} - + {% if package.featured %} + featured + {% endif %} + {% if package.example %} + example + {% endif %}

{{ package.description }}