Skip to content

Commit

Permalink
Fix #6506
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 16, 2012
1 parent 0efbf62 commit a0d606b
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 23 deletions.
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *


class HelloWorld:

def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
self.canvas = iface.mapCanvas()

def initGui(self):
# Create action that will start plugin
self.action = QAction(QIcon(":/plugins/"), "&HelloWorld", self.iface.mainWindow())
# connect the action to the run method
QObject.connect(self.action, SIGNAL("activated()"), self.hello_world)

# Add toolbar button and menu item
self.iface.addPluginToMenu("HelloWorld", self.action)


def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu("HelloWorld",self.action)



# run
def hello_world(self):
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate('HelloWorld', "HelloWorld"), QCoreApplication.translate('HelloWorld', "HelloWorld"))
return




if __name__ == "__main__":
pass
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
"""
This script initializes the plugin, making it known to QGIS.
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,31 @@
[general]
name=HelloWorld
qgisMinimumVersion=1.8
description=This is a test plugin for greeting the
(going multiline) world, version is 1.6
version=version 1.6
author=Alessandr� Pasott�
email=apasotti@gmail.com


changelog=this is a very
very<br/>
very
very
very
very long multiline changelog


tags= wkt, raster,hello world, spaced tag , tag

tracker=http://bugs.itopen.it
homepage=http://www.itopen.it
repository=http://www.itopen.it/repo



experimental=True


; change icon...
icon=icon.png
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *


class HelloWorld:

def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
self.canvas = iface.mapCanvas()

def initGui(self):
# Create action that will start plugin
self.action = QAction(QIcon(":/plugins/"), "&HelloWorld", self.iface.mainWindow())
# connect the action to the run method
QObject.connect(self.action, SIGNAL("activated()"), self.hello_world)

# Add toolbar button and menu item
self.iface.addPluginToMenu("HelloWorld", self.action)


def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu("HelloWorld",self.action)



# run
def hello_world(self):
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate('HelloWorld', "HelloWorld"), QCoreApplication.translate('HelloWorld', "HelloWorld"))
return




if __name__ == "__main__":
pass
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
"""
This script initializes the plugin, making it known to QGIS.
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,31 @@
[general]
name=HelloWorld
qgisMinimumVersion=1.8
description=This is a test plugin for greeting the
(going multiline) world, version is 1.7
version=version 1.7
author=Alessandro Pasotti
email=apasotti@gmail.com


changelog=this is a very
very<br/>
very
very
very
very long multiline changelog


tags= wkt, raster,hello world, spaced tag , tag

tracker=http://bugs.itopen.it
homepage=http://www.itopen.it
repository=http://www.itopen.it/repo



experimental=True


; change icon...
icon=icons/icon.png
65 changes: 42 additions & 23 deletions qgis-app/plugins/views.py
Expand Up @@ -217,12 +217,15 @@ def plugin_upload(request):
plugin.description = plugin_data['description']
plugin.author = plugin_data['author']
plugin.email = plugin_data['email']
plugin.icon = plugin_data['icon']
is_new = False
except Plugin.DoesNotExist:
plugin = Plugin(**plugin_data)
is_new = True

# Check icon, don't change if not valid
if plugin_data['icon']:
plugin.icon = plugin_data['icon']

# Other optional fields
warnings = []
if form.cleaned_data.get('homepage'):
Expand All @@ -238,7 +241,8 @@ def plugin_upload(request):
elif not plugin.repository:
warnings.append(_('<strong>repository</strong> field is empty, this field is not required but is recommended, please consider adding it to metadata.'))



# Save main Plugin object
plugin.save()

if is_new:
Expand Down Expand Up @@ -544,9 +548,13 @@ def _main_plugin_update(request, plugin, form):
Updates the main plugin object from version metadata
"""
# Update plugin from metadata
for f in ['icon', 'name', 'author', 'email', 'description', 'homepage', 'tracker']:
for f in ['name', 'author', 'email', 'description', 'homepage', 'tracker']:
if form.cleaned_data.get(f):
setattr(plugin, f, form.cleaned_data.get(f))

# Icon has a special treatment
if form.cleaned_data.get('icon_file'):
setattr(plugin, 'icon', form.cleaned_data.get('icon_file'))
if form.cleaned_data.get('tags'):
plugin.tags.set(*[t.strip().lower() for t in form.cleaned_data.get('tags').split(',')])
plugin.save()
Expand All @@ -568,20 +576,26 @@ def version_create(request, package_name):

form = PluginVersionForm(request.POST, request.FILES, instance=version, is_trusted=request.user.has_perm('plugins.can_approve'))
if form.is_valid():
new_object = form.save()
msg = _("The Plugin Version has been successfully created.")
messages.success(request, msg, fail_silently=True)
# The approved flag is also controlled in the form, but we
# are checking it here in any case for additional security
if not request.user.has_perm('plugins.can_approve'):
new_object.approved = False
new_object.save()
messages.warning(request, _('You do not have approval permissions, plugin version has been set unapproved.'), fail_silently=True)
if form.cleaned_data.get('icon_file'):
form.cleaned_data['icon'] = form.cleaned_data.get('icon_file')
_main_plugin_update(request, new_object.plugin, form)
_check_optional_metadata(form, request)
return HttpResponseRedirect(new_object.plugin.get_absolute_url())
try:
new_object = form.save()
msg = _("The Plugin Version has been successfully created.")
messages.success(request, msg, fail_silently=True)
# The approved flag is also controlled in the form, but we
# are checking it here in any case for additional security
if not request.user.has_perm('plugins.can_approve'):
new_object.approved = False
new_object.save()
messages.warning(request, _('You do not have approval permissions, plugin version has been set unapproved.'), fail_silently=True)
if form.cleaned_data.get('icon_file'):
form.cleaned_data['icon'] = form.cleaned_data.get('icon_file')
_main_plugin_update(request, new_object.plugin, form)
_check_optional_metadata(form, request)
return HttpResponseRedirect(new_object.plugin.get_absolute_url())
except (IntegrityError, ValidationError, DjangoUnicodeDecodeError), e:
messages.error(request, e, fail_silently=True)
transaction.rollback()
connection.close()
return HttpResponseRedirect(plugin.get_absolute_url())
else:
form = PluginVersionForm(is_trusted=request.user.has_perm('plugins.can_approve'))

Expand All @@ -601,12 +615,17 @@ def version_update(request, package_name, version):
if request.method == 'POST':
form = PluginVersionForm(request.POST, request.FILES, instance=version, is_trusted=request.user.has_perm('plugins.can_approve'))
if form.is_valid():
new_object = form.save()
# update metadata for the main plugin object
_main_plugin_update(request, new_object.plugin, form)
msg = _("The Plugin Version has been successfully updated.")
messages.success(request, msg, fail_silently=True)
return HttpResponseRedirect(new_object.plugin.get_absolute_url())
try:
new_object = form.save()
# update metadata for the main plugin object
_main_plugin_update(request, new_object.plugin, form)
msg = _("The Plugin Version has been successfully updated.")
messages.success(request, msg, fail_silently=True)
except (IntegrityError, ValidationError, DjangoUnicodeDecodeError), e:
messages.error(request, e, fail_silently=True)
transaction.rollback()
connection.close()
return HttpResponseRedirect(plugin.get_absolute_url())
else:
form = PluginVersionForm(instance=version, is_trusted=request.user.has_perm('plugins.can_approve'))

Expand Down

0 comments on commit a0d606b

Please sign in to comment.