WIP featured app multiselect
This commit is contained in:
Родитель
4467b4139f
Коммит
e42e0711d2
|
@ -63,18 +63,30 @@ function appslistXHR(verb, data) {
|
|||
|
||||
$(document).ready(function(){
|
||||
$("#featured-webapps").delegate(
|
||||
'.remove', 'click', _pd(function() {
|
||||
deleteFromAppsList($("#categories"),
|
||||
$(this).data("id"));
|
||||
}));
|
||||
$("#featured-webapps").delegate(
|
||||
"select.localepicker", "change", _pd(function (e) {
|
||||
'.remove',
|
||||
'click',
|
||||
_pd(function() {
|
||||
deleteFromAppsList($("#categories"), $(this).data("id"));
|
||||
})
|
||||
);
|
||||
$('#featured-webapps').delegate(
|
||||
'select.localepicker',
|
||||
'change',
|
||||
_pd(function (e) {
|
||||
var region = $(e.target);
|
||||
$.ajax({type: 'POST',
|
||||
url: region.data("url"),
|
||||
data: {"region": region.val(),
|
||||
"app": region.data("id")}});
|
||||
}));
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: region.data('url'),
|
||||
data: {
|
||||
'region':
|
||||
_(region.children('option'))
|
||||
.filter(function(opt) {return opt.selected})
|
||||
.map(function(sopt) {return sopt.value}),
|
||||
'app': region.data('id')
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
var categories = $("#categories");
|
||||
var appslist = $("#featured-webapps");
|
||||
var p = $.ajax({type: 'GET',
|
||||
|
|
|
@ -10,8 +10,15 @@ class FeaturedApp(models.Model):
|
|||
app = models.ForeignKey(Webapp, null=False)
|
||||
category = models.ForeignKey(Category, null=True)
|
||||
is_sponsor = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
db_table = 'zadmin_featuredapp'
|
||||
|
||||
|
||||
class FeaturedAppRegionExclusion(models.Model):
|
||||
featured_app = models.ForeignKey(FeaturedApp, null=False)
|
||||
region = models.PositiveIntegerField(default=mkt.regions.WORLDWIDE.id,
|
||||
db_index=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'zadmin_featuredapp'
|
||||
db_table = 'zadmin_featuredapp_regionexclusion'
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>{% if row.is_sponsor %}Sponsored{% else %}Not sponsored{% endif %}</td>
|
||||
<td><select class="localepicker"
|
||||
data-url="{{ url('zadmin.set_region_ajax') }}"
|
||||
data-id="{{ row.pk }}">
|
||||
{% for locName, loc in regions %}
|
||||
<td>
|
||||
<select class="localepicker" multiple
|
||||
data-url="{{ url('zadmin.set_region_ajax') }}"
|
||||
data-id="{{ row.pk }}">
|
||||
{%- for locName, loc in regions -%}
|
||||
<option value="{{ loc.slug }}"
|
||||
{%- if loc.slug == row.region -%}
|
||||
selected="selected"
|
||||
{%- endif -%}
|
||||
>{{ loc.name }}</option>
|
||||
{%- if loc.slug == row.region %} selected{%- endif -%}
|
||||
>{{ loc.name }}</option>
|
||||
{%- endfor -%}
|
||||
</select>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Загрузка…
Ссылка в новой задаче