зеркало из https://github.com/mozilla/FlightDeck.git
Merge pull request #77 from pennyfx/tags
Added featured and example tags to packages, updated styles, fixed admin template bug
This commit is contained in:
Коммит
7d21cba1b3
|
@ -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 %}
|
||||
<style type="text/css">
|
||||
.UI_Forms .UI_Form_Actions li {
|
||||
float:none;
|
||||
display:inline-block;
|
||||
float: none;
|
||||
display: inline-block;
|
||||
}
|
||||
#package_msg{
|
||||
color: red;
|
||||
}
|
||||
.package_meta li span{
|
||||
font-weight: bold;
|
||||
margin-right: 4px;
|
||||
}
|
||||
#package_actions label{
|
||||
display: inline;
|
||||
}
|
||||
#package_actions input, #package_actions button{
|
||||
display: inline;
|
||||
border: solid 1px #ccc;
|
||||
}
|
||||
#package_actions button{
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<form method="post" action="" class="UI_Forms">
|
||||
<h2 class="UI_Heading" style="padding-top:3em;">Search</h2>
|
||||
{% if message %}
|
||||
<p><strong>{{message}}</strong></p>
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
<ul class="UI_Form_Actions">
|
||||
<li>
|
||||
<button name="action" value="setup_mapping" type="submit">Setup Mapping</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="action" value="index_all" type="submit">Index All</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
{% block head %}
|
||||
<script type="text/javascript">
|
||||
var admin_settings = {
|
||||
'get_package_url':'{{ url('admin_get_package') }}',
|
||||
'update_package_url':'{{ url('admin_update_package') }}',
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="/media/base/js/Admin.js" ></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<form method="post" action="" class="UI_Forms">
|
||||
<h2 class="UI_Heading" style="padding-top:3em;">Crons</h2>
|
||||
{% if message %}
|
||||
<p><strong>{{message}}</strong></p>
|
||||
{% endif %}
|
||||
{{ safe_csrf_token()|safe }}
|
||||
<ul class="UI_Form_Actions">
|
||||
<li>
|
||||
<button name="action" value="setup_mapping" type="submit">Setup Mapping</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="action" value="index_all" type="submit">Index All</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
|
||||
<div id="package_actions">
|
||||
<h2 class="UI_Heading" style="padding-top:3em;">Package <span id="package_msg"></span></h2>
|
||||
<label for="txt_package_id">Fetch Package by Id</label>
|
||||
<input type="text" id="txt_package_id" /> <button type="button" id="btn_find_package">Find</button>
|
||||
<div id="package_item"></div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
<div class="result package {{ package.is_addon()|yesno("addon,library") }}">
|
||||
<input class="package_id" type="hidden" value="{{ package.id }}" />
|
||||
<ul class="package_meta">
|
||||
<li><span>name:</span>{{package.full_name}}<li>
|
||||
<li><span>package type:</span>{{ package.is_addon()|yesno("addon,library") }}<li>
|
||||
<li><span>author:</span>
|
||||
<a href="{{ url('person_public_profile', package.author.username) }}">{{ package.author.get_profile() }}</a></li>
|
||||
<li><span>version_name:</span>{{package.version_name}}<li>
|
||||
<li><span>version_id:</span>{{package.version_id}}</li>
|
||||
<li><span>active:</span>{{package.active}}</li>
|
||||
<li><span>deleted:</span>{{package.deleted}}</li>
|
||||
<li><span>created:</span>{{package.created_at}}</li>
|
||||
<li><span>updated:</span>{{package.last_update}}</li>
|
||||
<li><span>description:</span><p>{{package.description}}</p><li>
|
||||
</ul>
|
||||
<ul class="UI_Actions">
|
||||
<li class="UI_Package_Featured {{ 'pressed' if package.featured else '' }}"><a href="">Featured</a></li>
|
||||
<li class="UI_Package_Example {{ 'pressed' if package.example else '' }}"><a href="">Example</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
<h2 class="UI_Heading" style="padding-top: 3em">Free space</h2>
|
||||
<ul>
|
||||
{% for path, size in free.items() %}
|
||||
<li>{{ path }}: {{ size }}kB</li>
|
||||
{% for path, size in free %}
|
||||
<li>{{ path }}: {{ size|filesizeformat }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -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'),
|
||||
)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2,21 +2,26 @@
|
|||
<div class="result package {{ package.is_addon()|yesno("addon,library") }}">
|
||||
<h3>
|
||||
<a href="{{ package.get_absolute_url() }}">{{ package.full_name }}</a>
|
||||
|
||||
{% if package.featured %}
|
||||
<span class="featured" title="Featured">featured</span>
|
||||
{% endif %}
|
||||
{% if package.example %}
|
||||
<span class="example" title="Example">example</span>
|
||||
{% endif %}
|
||||
</h3>
|
||||
<p class="description">{{ package.description }}</p>
|
||||
<ul class="search_meta">
|
||||
<li><span>author:</span>
|
||||
<li title="Author" class="author"><span> </span>
|
||||
<a href="{{ url('person_public_profile', package.author.username) }}">{{ package.author.get_profile() }}</a></span></li>
|
||||
<li><span>forks:</span>
|
||||
<li title="Forks" class="forks"><span> </span>
|
||||
{{ package.search_meta.copies_count }}</li>
|
||||
{% if package.is_library() %}
|
||||
<li><span>used:</span>
|
||||
{{ package.search_meta.times_depended }} times</li>
|
||||
<li title="Number of times used by other Addons or Libraries" class="used"><span> </span>
|
||||
{{ package.search_meta.times_depended }}</li>
|
||||
{% endif %}
|
||||
<li><span>activity:</span>
|
||||
<li title="Development Activity" class="activity"><span> </span>
|
||||
{{ get_activity_level_UI(package.search_meta.activity) }}</li>
|
||||
<li><span>size:</span>
|
||||
<li title="Package Size" class="size"><span> </span>
|
||||
{{ package.search_meta.size|filesizeformat }}</li>
|
||||
</ul>
|
||||
<ul class="UI_Actions">
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
window.addEvent('domready', function(e){
|
||||
var setMsg = function(msg){
|
||||
var elem = $('package_msg');
|
||||
elem.set('html', msg);
|
||||
setTimeout(function(){
|
||||
elem.set('html','');
|
||||
},2000);
|
||||
}
|
||||
$('btn_find_package').addEvent('click', function(e){
|
||||
var r = new Request({
|
||||
url: admin_settings.get_package_url,
|
||||
onSuccess: function(p){
|
||||
$('package_item').set('html',p);
|
||||
},
|
||||
onFailure: function(err){
|
||||
console.log(err);
|
||||
setMsg(err.status + " " + err.statusText);
|
||||
}
|
||||
});
|
||||
r.get('package_id='+ $('txt_package_id').value);
|
||||
|
||||
});
|
||||
|
||||
var updatePackage = function(elem, field, callback){
|
||||
var id = elem.getParent('.package').getElement('.package_id').value,
|
||||
enabled = elem.getParent().hasClass('pressed'),
|
||||
r = new Request({
|
||||
url: admin_settings.update_package_url,
|
||||
method: 'post',
|
||||
onSuccess: function(p){
|
||||
setMsg("updated");
|
||||
elem.getParent().toggleClass('pressed');
|
||||
if (callback) callback();
|
||||
},
|
||||
onFailure: function(err){
|
||||
if(err.status == 404){
|
||||
$('package_item').set('html', '');
|
||||
}
|
||||
setMsg(err.status + " " + err.statusText);
|
||||
}
|
||||
});
|
||||
r.send('package_id='+id+'&'+field+'='+!enabled);
|
||||
};
|
||||
|
||||
$('package_item').addEvent('click:relay(.UI_Package_Featured a)', function(e){
|
||||
e.stop();
|
||||
updatePackage(this, 'featured')
|
||||
});
|
||||
$('package_item').addEvent('click:relay(.UI_Package_Example a)', function(e){
|
||||
e.stop();
|
||||
updatePackage(this, 'example')
|
||||
});
|
||||
});
|
|
@ -1 +1 @@
|
|||
Subproject commit 85f0e6f71ffeeb104f20da889c1f1a5edea624a1
|
||||
Subproject commit ab0f4bd7077e1dfdba70bbdaea1be83d14405b83
|
|
@ -160,7 +160,8 @@ body {
|
|||
color:#2854BB;
|
||||
/*color:#478CDE;*/
|
||||
font-size:1.3em;
|
||||
letter-spacing: -0.5px;
|
||||
letter-spacing: -0.5px;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
#SearchResults .package h3 span {
|
||||
|
@ -192,12 +193,53 @@ body {
|
|||
}
|
||||
#SearchResults .package ul.search_meta li{
|
||||
float:left;
|
||||
color:#444;
|
||||
margin-right:10px;
|
||||
color:#444;
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li span{
|
||||
color:#666;
|
||||
#SearchResults .package ul.search_meta li span{
|
||||
opacity: 0.35;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li.size span{
|
||||
background-image:url('../img/size.png');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#SearchResults .package ul.search_meta li.size{
|
||||
width:75px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li.author span{
|
||||
background-image:url('../img/person.png');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#SearchResults .package ul.search_meta li.author{
|
||||
width:100px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li.forks span{
|
||||
background-image:url('../img/fork.png');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#SearchResults .package ul.search_meta li.forks{
|
||||
width: 42px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li.used span{
|
||||
background-image:url('../img/bookmark.png');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#SearchResults .package ul.search_meta li.used{
|
||||
width: 52px;
|
||||
}
|
||||
|
||||
#SearchResults .package ul.search_meta li.activity span{
|
||||
background-image:url('../img/chart.png');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#SearchResults .package ul.search_meta li.activity{
|
||||
width: 65px;
|
||||
}
|
||||
|
||||
#SearchResults .UI_Sorting{
|
||||
|
@ -209,7 +251,30 @@ body {
|
|||
font-size:0.8em;
|
||||
}
|
||||
|
||||
|
||||
#SearchResults .featured{
|
||||
background: -moz-linear-gradient(center top , #D3B000 0%, #CC952E 100%) repeat scroll 0 0 transparent;
|
||||
border: 1px solid #AD8027;
|
||||
border-radius: 2px 2px 2px 2px;
|
||||
color: white !important;
|
||||
font-size: 0.7em;
|
||||
font-weight: bold;
|
||||
padding: 2px 5px 2px 6px;
|
||||
position: relative;
|
||||
text-shadow: 0 -1px 0 #AD8027;
|
||||
top: -3px;
|
||||
}
|
||||
#SearchResults .example{
|
||||
background: -moz-linear-gradient(center top , #638ced 0%, #2170ef 100%) repeat scroll 0 0 transparent;
|
||||
border: 1px solid #2170ef;
|
||||
border-radius: 2px 2px 2px 2px;
|
||||
color: white !important;
|
||||
font-size: 0.7em;
|
||||
font-weight: bold;
|
||||
padding: 2px 5px 2px 6px;
|
||||
position: relative;
|
||||
text-shadow: 0 -1px 0 #2170ef;
|
||||
top: -3px;
|
||||
}
|
||||
|
||||
|
||||
#SearchResults .see-more {
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.9 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.9 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 236 B |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 201 B |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.1 KiB |
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `jetpack_package` ADD `featured` BOOLEAN DEFAULT FALSE;
|
||||
ALTER TABLE `jetpack_package` ADD `example` BOOLEAN DEFAULT FALSE;
|
Загрузка…
Ссылка в новой задаче