Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade fixes #213

Merged
merged 13 commits into from Apr 15, 2020
2 changes: 1 addition & 1 deletion cartoview/app_manager/admin.py
Expand Up @@ -30,7 +30,7 @@ def uninstall_selected(modeladmin, request, queryset):

@admin.register(App)
class AppAdmin(admin.ModelAdmin):
ordering = ('order', )
ordering = ('order',)
actions = [uninstall_selected]


Expand Down
1 change: 0 additions & 1 deletion cartoview/app_manager/api.py
Expand Up @@ -10,7 +10,6 @@
from tastypie.utils import trailing_slash

from cartoview.log_handler import get_logger

from .serializers import HTMLSerializer

logger = get_logger(__name__)
Expand Down
2 changes: 2 additions & 0 deletions cartoview/app_manager/decorators.py
Expand Up @@ -42,6 +42,7 @@ def restart_enabled(func):
def wrap(*args, **kwargs):
if not getattr(settings, "CARTOVIEW_TEST", False):
return func(*args, **kwargs)

return wrap


Expand All @@ -55,4 +56,5 @@ def wrap(*args, **kwargs):
if hasattr(this, '_rollback'):
this._rollback()
raise e

return wrap
7 changes: 2 additions & 5 deletions cartoview/app_manager/forms.py
Expand Up @@ -17,9 +17,9 @@
class AppInstallerForm(ModelForm):
error_messages = {
'duplicate_app_name':
_("An application with the same user has already installed."),
_("An application with the same user has already installed."),
'invalid_package_file':
_("The uploaded file is not an application package."),
_("The uploaded file is not an application package."),
}
package_file = FileField()

Expand All @@ -29,14 +29,12 @@ class Meta(object):


class AppForm(ModelForm):

class Meta(object):
model = App
fields = ("title",)


class AppInstanceForm(TranslationModelForm):

class Meta(object):
model = AppInstance
fields = [
Expand All @@ -46,7 +44,6 @@ class Meta(object):


class AppInstanceEditForm(ResourceBaseForm):

class Meta(ResourceBaseForm.Meta):
model = AppInstance
exclude = ResourceBaseForm.Meta.exclude
2 changes: 1 addition & 1 deletion cartoview/app_manager/helpers.py
Expand Up @@ -48,7 +48,7 @@ def get_perm(fname):
def make_writeable_recursive(path):
for root, dirs, files in os.walk(path, topdown=False):
for dir in [os.path.join(root, d) for d in dirs]:
os.chmod(dir, get_perm(dir) | stat.S_IRUSR | # noqa
os.chmod(dir, get_perm(dir) | stat.S_IRUSR | # noqa
stat.S_IRGRP | stat.S_IROTH)
for file in [os.path.join(root, f) for f in files]:
os.chmod(file, get_perm(file) | stat.S_IRUSR | # noqa
Expand Down
11 changes: 5 additions & 6 deletions cartoview/app_manager/installer.py
Expand Up @@ -23,13 +23,12 @@
from cartoview.apps_handler.config import CartoviewApp
from cartoview.log_handler import get_logger
from cartoview.store_api.api import StoreAppResource, StoreAppVersion

from ..apps_handler.req_installer import (ReqFileException,
ReqFilePermissionException,
ReqInstaller)
from .decorators import restart_enabled, rollback_on_failure
from .exceptions import AppAlreadyInstalledException
from .models import App, AppStore, AppType
from ..apps_handler.req_installer import (ReqFileException,
ReqFilePermissionException,
ReqInstaller)

logger = get_logger(__name__)
install_app_batch = getattr(settings, 'INSTALL_APP_BAT', None)
Expand Down Expand Up @@ -140,7 +139,7 @@ def get_store(self, store_id=None):

def get_app_version(self):
if not self.version or self.version == 'latest' or \
self.info.latest_version.version == self.version:
self.info.latest_version.version == self.version:
self.version = self.info.latest_version
else:
data = self._request_rest_data("appversion/?app__name=", self.name,
Expand Down Expand Up @@ -359,7 +358,7 @@ def uninstall(self, restart=True):
app_installer = AppInstaller(
app.name, self.store.id, app.version, user=self.user)
dependencies = app_installer.version.dependencies \
if app_installer.version else {}
if app_installer.version else {}
if self.name in dependencies.keys():
app_installer.uninstall(restart=False)
try:
Expand Down
@@ -1,11 +1,11 @@
import importlib

from django.core.management.base import BaseCommand
from geonode.people.models import Profile

from cartoview.app_manager.models import App, AppType
from cartoview.apps_handler.config import CartoviewApp
from cartoview.log_handler import get_logger
from geonode.people.models import Profile

logger = get_logger(with_formatter=True)

Expand Down
@@ -1,9 +1,11 @@
from __future__ import print_function

import requests
from django.core.management.base import BaseCommand

from cartoview.app_manager.installer import AppJson, remove_unwanted
from cartoview.app_manager.models import App
from cartoview.store_api.api import StoreAppResource
from django.core.management.base import BaseCommand


class Command(BaseCommand):
Expand Down
15 changes: 7 additions & 8 deletions cartoview/app_manager/migrations/0001_initial.py
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
('sites', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
Expand Down Expand Up @@ -54,7 +53,7 @@ class Migration(migrations.Migration):
('order', models.IntegerField(default=0, null=True)),
('installed_by', models.ForeignKey(
blank=True, to=settings.AUTH_USER_MODEL, null=True)),
],),
], ),
migrations.CreateModel(
name='AppInstance',
fields=[
Expand All @@ -73,7 +72,7 @@ class Migration(migrations.Migration):
options={
'abstract': False,
},
bases=('base.resourcebase',),),
bases=('base.resourcebase',), ),
migrations.CreateModel(
name='AppStore',
fields=[
Expand All @@ -85,7 +84,7 @@ class Migration(migrations.Migration):
('name', models.CharField(max_length=256)),
('url', models.URLField(verbose_name=b'App Store URL')),
('is_default', models.BooleanField(default=False)),
],),
], ),
migrations.CreateModel(
name='AppTag',
fields=[
Expand All @@ -96,7 +95,7 @@ class Migration(migrations.Migration):
primary_key=True)),
('name', models.CharField(
max_length=200, unique=True, null=True, blank=True)),
],),
], ),
migrations.CreateModel(
name='Logo',
fields=[
Expand All @@ -107,14 +106,14 @@ class Migration(migrations.Migration):
primary_key=True)),
('logo', models.ImageField(upload_to=b'')),
('site', models.OneToOneField(to='sites.Site')),
],),
], ),
migrations.AddField(
model_name='app',
name='store',
field=models.ForeignKey(to='app_manager.AppStore', null=True),),
field=models.ForeignKey(to='app_manager.AppStore', null=True), ),
migrations.AddField(
model_name='app',
name='tags',
field=models.ManyToManyField(to='app_manager.AppTag',
blank=True),),
blank=True), ),
]
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0001_initial'),
]
Expand Down
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0002_auto_20171001_1057'),
]
Expand Down
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
('taggit', '0002_auto_20150616_2121'),
('app_manager', '0003_auto_20171002_0445'),
Expand Down
1 change: 0 additions & 1 deletion cartoview/app_manager/migrations/0005_delete_apptag.py
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0004_auto_20171002_0446'),
]
Expand Down
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0005_delete_apptag'),
]
Expand Down
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0006_app_default_config'),
]
Expand Down
2 changes: 1 addition & 1 deletion cartoview/app_manager/migrations/0008_appinstance_logo.py
Expand Up @@ -2,11 +2,11 @@
from __future__ import unicode_literals

from django.db import migrations, models

import cartoview.app_manager.models


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0007_auto_20180128_0116'),
]
Expand Down
5 changes: 3 additions & 2 deletions cartoview/app_manager/migrations/0009_auto_20180920_1659.py
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0008_appinstance_logo'),
]
Expand All @@ -14,7 +13,9 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='appstore',
name='server_type',
field=models.CharField(default='Geoserver', max_length=256, choices=[('Exchange', 'Exchange'), ('Geoserver', 'Geoserver'), ('QGISServer', 'QGISServer')]),
field=models.CharField(default='Geoserver', max_length=256,
choices=[('Exchange', 'Exchange'), ('Geoserver', 'Geoserver'),
('QGISServer', 'QGISServer')]),
),
migrations.AlterField(
model_name='app',
Expand Down
3 changes: 1 addition & 2 deletions cartoview/app_manager/migrations/0010_auto_20181118_1333.py
Expand Up @@ -2,12 +2,11 @@
# Generated by Django 1.11.16 on 2018-11-18 13:33
from __future__ import unicode_literals

from django.db import migrations
import django.db.models.manager
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('app_manager', '0009_auto_20180920_1659'),
]
Expand Down
8 changes: 4 additions & 4 deletions cartoview/app_manager/models.py
Expand Up @@ -12,15 +12,15 @@
from django.template.defaultfilters import slugify
from django.utils.encoding import python_2_unicode_compatible
from future import standard_library
from geonode.base.models import ResourceBase, resourcebase_post_save
from geonode.maps.models import Map as GeonodeMap
from geonode.security.models import remove_object_permissions
from guardian.shortcuts import assign_perm
from jsonfield import JSONField
from taggit.managers import TaggableManager

from cartoview.apps_handler.config import CartoviewApp
from cartoview.log_handler import get_logger
from geonode.base.models import ResourceBase, resourcebase_post_save
from geonode.maps.models import Map as GeonodeMap
from geonode.security.models import remove_object_permissions

logger = get_logger(__name__)

Expand Down Expand Up @@ -214,7 +214,7 @@ class AppInstance(ResourceBase):
upload_to=get_app_logo_path, blank=True, null=True)

def get_absolute_url(self):
return reverse('appinstance_detail', args=(self.id, ))
return reverse('appinstance_detail', args=(self.id,))

def __str__(self):
return self.title
Expand Down
2 changes: 0 additions & 2 deletions cartoview/app_manager/resources.py
Expand Up @@ -22,7 +22,6 @@ class BaseMeta(object):


class BaseModelResource(ModelResource):

class Meta(BaseMeta):
pass

Expand Down Expand Up @@ -68,7 +67,6 @@ def edit(self, request, pk, **kwargs):


class FileUploadResource(BaseModelResource):

class Meta(BaseModelResource.Meta):
object_class = None
serializer = MultipartFormSerializer()
Expand Down