Skip to content

Commit

Permalink
Merge pull request #3151 from hishamkaram/master
Browse files Browse the repository at this point in the history
set thumbnail function  for geonode-client
  • Loading branch information
Alessio Fabiani authored Jul 21, 2017
2 parents a70ecbe + 56794c2 commit 4428ac9
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 91 deletions.
56 changes: 43 additions & 13 deletions geonode/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,25 @@

from modeltranslation.admin import TranslationAdmin

from geonode.base.models import (TopicCategory, SpatialRepresentationType, Region, RestrictionCodeType,
ContactRole, Link, Backup, License, HierarchicalKeyword)
from geonode.base.models import (
TopicCategory,
SpatialRepresentationType,
Region,
RestrictionCodeType,
ContactRole,
Link,
Backup,
License,
HierarchicalKeyword)
from django.http import HttpResponseRedirect


def metadata_batch_edit(modeladmin, request, queryset):
ids = ','.join([str(element.pk) for element in queryset])
resource = queryset[0].class_name.lower()
return HttpResponseRedirect('/{}s/metadata/batch/{}/'.format(resource, ids))
return HttpResponseRedirect(
'/{}s/metadata/batch/{}/'.format(resource, ids))


metadata_batch_edit.short_description = 'Metadata batch edit'

Expand Down Expand Up @@ -74,13 +84,18 @@ def run(self, request, queryset):
for siteObj in queryset:
self.message_user(request, "Executed Backup: " + siteObj.name)
out = StringIO.StringIO()
call_command('backup', force_exec=True, backup_dir=siteObj.base_folder, stdout=out)
call_command(
'backup',
force_exec=True,
backup_dir=siteObj.base_folder,
stdout=out)
value = out.getvalue()
if value:
siteObj.location = value
siteObj.save()
else:
self.message_user(request, siteObj.name + " backup failed!")
self.message_user(
request, siteObj.name + " backup failed!")
else:
context = {
"objects_name": "Backups",
Expand All @@ -89,8 +104,11 @@ def run(self, request, queryset):
'cancellable_backups': [siteObj],
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
}
return TemplateResponse(request, 'admin/backups/confirm_cancel.html', context,
current_app=self.admin_site.name)
return TemplateResponse(
request,
'admin/backups/confirm_cancel.html',
context,
current_app=self.admin_site.name)


def restore(self, request, queryset):
Expand All @@ -105,9 +123,12 @@ def restore(self, request, queryset):
self.message_user(request, "Executed Restore: " + siteObj.name)
out = StringIO.StringIO()
if siteObj.location:
call_command('restore', force_exec=True, backup_file=str(siteObj.location).strip(), stdout=out)
call_command(
'restore', force_exec=True, backup_file=str(
siteObj.location).strip(), stdout=out)
else:
self.message_user(request, siteObj.name + " backup not ready!")
self.message_user(
request, siteObj.name + " backup not ready!")
else:
context = {
"objects_name": "Restores",
Expand All @@ -116,8 +137,11 @@ def restore(self, request, queryset):
'cancellable_backups': [siteObj],
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
}
return TemplateResponse(request, 'admin/backups/confirm_cancel.html', context,
current_app=self.admin_site.name)
return TemplateResponse(
request,
'admin/backups/confirm_cancel.html',
context,
current_app=self.admin_site.name)


run.short_description = "Run the Backup"
Expand All @@ -142,7 +166,12 @@ class LicenseAdmin(MediaTranslationAdmin):
class TopicCategoryAdmin(MediaTranslationAdmin):
model = TopicCategory
list_display_links = ('identifier',)
list_display = ('identifier', 'description', 'gn_description', 'fa_class', 'is_choice')
list_display = (
'identifier',
'description',
'gn_description',
'fa_class',
'is_choice')
if settings.MODIFY_TOPICCATEGORY is False:
exclude = ('identifier', 'description',)

Expand Down Expand Up @@ -236,4 +265,5 @@ class ResourceBaseAdminForm(autocomplete_light.ModelForm):
# which prevents app startup. Therefore, we defer setting the widget until
# after that's done.
keywords = TaggitField(required=False)
keywords.widget = TaggitWidget(autocomplete='HierarchicalKeywordAutocomplete')
keywords.widget = TaggitWidget(
autocomplete='HierarchicalKeywordAutocomplete')
16 changes: 12 additions & 4 deletions geonode/layers/templates/layers/layer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,18 @@ <h4>{% trans "External service layer" %}</h4>
{% endif %}
</script>
<script type="text/javascript">
$('#set_thumbnail').click(function(){
createMapThumbnail();
$('#edit-layer').modal('toggle');
});
{% if preview == 'react' %}
$('#set_thumbnail').click(function(){
window.setThumbnail({{resource.id}})
$('#edit-layer').modal('toggle');
});
{% else %}
$('#set_thumbnail').click(function(){
createMapThumbnail();
$('#edit-layer').modal('toggle');
});
{% endif %}

</script>
{% if GEONODE_SECURITY_ENABLED %}
{% include "_permissions_form_js.html" %}
Expand Down
Loading

0 comments on commit 4428ac9

Please sign in to comment.