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

[Fixes #12368] Introduce geonode-importer in geonode-core #12570

Merged
merged 78 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
96972a7
[Fixes #12124] GNIP 100: Assets (#12335)
mattiagiupponi Jun 18, 2024
d008bad
[Fixes #12226] Directory assets (#12337)
mattiagiupponi Jun 18, 2024
51458d5
[Fixes #12341] Asset download handler and link generator (#12343)
mattiagiupponi Jun 20, 2024
07abdbb
Test Include Importer in GeoNode
mattiagiupponi Jun 24, 2024
39d0174
Test Include Importer in GeoNode
mattiagiupponi Jun 24, 2024
62ffc64
Test Include Importer in GeoNode
mattiagiupponi Jun 25, 2024
3eb786d
add importer
mattiagiupponi Jun 28, 2024
274cc5a
importer in core
mattiagiupponi Jul 2, 2024
ff0df25
[Fixes 12368] Fix import
mattiagiupponi Jul 2, 2024
890785f
[Fixes 12368] merge
mattiagiupponi Jul 2, 2024
2ce8fb7
[Fixes 12368] test fixing
mattiagiupponi Jul 2, 2024
354d250
[Fixes 12368] test fixing
mattiagiupponi Jul 2, 2024
c166aa5
[Fixes 12368] test fixing
mattiagiupponi Jul 3, 2024
5f26374
[Fixes 12368] test fixing
mattiagiupponi Jul 3, 2024
69e5dd6
merge with master
mattiagiupponi Sep 6, 2024
036837f
merge with master
mattiagiupponi Sep 6, 2024
8f8e35c
Importer in core
mattiagiupponi Sep 6, 2024
75061c7
Importer in core
mattiagiupponi Sep 6, 2024
a4646c4
Importer in core
mattiagiupponi Sep 6, 2024
f0bf1c9
Fix circleci build
mattiagiupponi Sep 9, 2024
26dc661
Fix circleci build
mattiagiupponi Sep 9, 2024
00d784d
Fix circleci build
mattiagiupponi Sep 9, 2024
1024162
Fix circleci build
mattiagiupponi Sep 9, 2024
549fa48
Fix circleci build
mattiagiupponi Sep 9, 2024
ee568ba
Fix circleci build
mattiagiupponi Sep 9, 2024
a8df5e6
Fix circleci build
mattiagiupponi Sep 9, 2024
0e10c27
Merge branch 'master' of github.com:GeoNode/geonode into importer_in_…
mattiagiupponi Sep 9, 2024
1ffa99a
Fix circleci build
mattiagiupponi Sep 9, 2024
e807861
Fix circleci build
mattiagiupponi Sep 9, 2024
ac876fc
Fix circleci build
mattiagiupponi Sep 9, 2024
8d0623e
Fix circleci build
mattiagiupponi Sep 9, 2024
20dff80
Fix circleci build
mattiagiupponi Sep 9, 2024
f6f28b1
Fix circleci build
mattiagiupponi Sep 10, 2024
b007748
Fix circleci build
mattiagiupponi Sep 10, 2024
377e764
Fix circleci build
mattiagiupponi Sep 10, 2024
3dc4ee5
Fix circleci build
mattiagiupponi Sep 10, 2024
4c6df84
Fix circleci build
mattiagiupponi Sep 10, 2024
18ad2c3
Fix circleci build
mattiagiupponi Sep 12, 2024
81083fc
Fix circleci build
mattiagiupponi Sep 12, 2024
99f3a63
Fix circleci build
mattiagiupponi Sep 12, 2024
38f1964
Fix circleci build
mattiagiupponi Sep 12, 2024
b80e9b7
Fix black formatting
mattiagiupponi Sep 12, 2024
e3633c3
Remove unused files
mattiagiupponi Sep 12, 2024
9605bf4
Remove unused code
mattiagiupponi Sep 13, 2024
f03b7a5
Remove unused code
mattiagiupponi Sep 13, 2024
78144ec
Remove unused code
mattiagiupponi Sep 13, 2024
46c19e4
Remove unused code
mattiagiupponi Sep 13, 2024
46bbc63
Removed unused function/deadcode
mattiagiupponi Sep 16, 2024
48dc552
Removed unused function/deadcode
mattiagiupponi Sep 16, 2024
7716ad1
Fix circleci build
mattiagiupponi Sep 16, 2024
a2a5033
Fix circleci build
mattiagiupponi Sep 16, 2024
f65e04a
Fix circleci build
mattiagiupponi Sep 17, 2024
5d7c10d
Fix circleci build
mattiagiupponi Sep 17, 2024
580f128
Fix circleci build
mattiagiupponi Sep 17, 2024
4443013
Fix circleci build
mattiagiupponi Sep 17, 2024
530340a
Fix circleci build
mattiagiupponi Sep 17, 2024
ad35ab9
add missing headers
mattiagiupponi Sep 17, 2024
56c6f80
Add connection between execution request and resource
mattiagiupponi Oct 11, 2024
78ca571
Merge branch 'master' of github.com:GeoNode/geonode into importer_in_…
mattiagiupponi Oct 11, 2024
9f38402
Fix dataset assign for sld and xml
mattiagiupponi Oct 11, 2024
e05ec14
[Fixes #] fix metadata handler
mattiagiupponi Oct 14, 2024
33d777f
[Fixes #] fix metadata handler
mattiagiupponi Oct 14, 2024
918b437
[Fixes #12368] add pre-validation step
mattiagiupponi Oct 15, 2024
e553227
[Fixes #12368] fix serializers for overwrite workflow
mattiagiupponi Oct 15, 2024
7bb9fd5
Merge branch 'master' of github.com:GeoNode/geonode into importer_in_…
mattiagiupponi Oct 15, 2024
51ef4e1
[Fixes #12368] fix replace
mattiagiupponi Oct 15, 2024
5d4f7a0
[Fixes #12368] fix replace
mattiagiupponi Oct 15, 2024
d35699e
[Fixes #12368] fix build
mattiagiupponi Oct 15, 2024
c072c87
[Fixes #12368] Fix build and broken tests
mattiagiupponi Oct 15, 2024
cab567f
[Fixes #12368] Fix build and broken tests
mattiagiupponi Oct 15, 2024
6d6aae2
[Fixes #12368] Fix build and broken tests
mattiagiupponi Oct 15, 2024
767dd0e
[Fixes #12368] Fix build and broken tests
mattiagiupponi Oct 15, 2024
1814b66
[Fixes #12368] Fix raster replace
mattiagiupponi Oct 15, 2024
6f7eee0
[Fixes #12368] Fix raster replace
mattiagiupponi Oct 15, 2024
e9ca690
[Fixes #12368] Fix sld serializer
mattiagiupponi Oct 15, 2024
d5210a4
[Fixes #12368] Fix sld serializer
mattiagiupponi Oct 15, 2024
a9fe907
[Fixes #12368] Fix vector replace
mattiagiupponi Oct 15, 2024
a1dff0a
[Fixes #12368] Fix vector replace
mattiagiupponi Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ workflows:
codecov_name: main_tests
load_docker_cache: false
save_docker_cache: false
test_suite: ./test.sh $(python -c "import sys;from geonode import settings;sys.stdout.write('\'' '\''.join([a+'\''.tests'\'' for a in settings.GEONODE_APPS if '\''security'\'' not in a and '\''geoserver'\'' not in a]))") geonode.thumbs.tests geonode.people.tests geonode.people.socialaccount.providers.geonode_openid_connect.tests
test_suite: ./test.sh $(python -c "import sys;from geonode import settings;sys.stdout.write('\'' '\''.join([a+'\''.tests'\'' for a in settings.GEONODE_APPS if '\''security'\'' not in a and '\''geoserver'\'' not in a and '\''upload'\'' not in a]))") geonode.thumbs.tests geonode.people.tests geonode.people.socialaccount.providers.geonode_openid_connect.tests
- build:
name: geonode_test_security
codecov_name: security_tests
Expand All @@ -128,14 +128,19 @@ workflows:
codecov_name: api
load_docker_cache: false
save_docker_cache: false
test_suite: ./test.sh geonode.api.tests geonode.base.api.tests geonode.layers.api.tests geonode.maps.api.tests geonode.documents.api.tests geonode.geoapps.api.tests geonode.upload.api.tests
test_suite: ./test.sh geonode.api.tests geonode.base.api.tests geonode.layers.api.tests geonode.maps.api.tests geonode.documents.api.tests geonode.geoapps.api.tests
- build:
name: geonode_test_csw
codecov_name: csw
load_docker_cache: false
save_docker_cache: false
test_suite: ./test.sh geonode.tests.csw geonode.catalogue.backends.tests

- build:
name: geonode_upload
codecov_name: importer
load_docker_cache: false
save_docker_cache: false
test_suite: ./test.sh geonode.upload
# TODO
# - build:
# name: geonode_test_integration_upload
Expand Down
10 changes: 7 additions & 3 deletions .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
BROKER_URL=amqp://guest:guest@rabbitmq:5672/
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=True
ASYNC_SIGNALS=False

SITEURL=http://localhost:8000/

Expand All @@ -49,6 +49,10 @@ ALLOWED_HOSTS="['django', 'localhost', '127.0.0.1']"
DEFAULT_BACKEND_UPLOADER=geonode.importer
TIME_ENABLED=True
MOSAIC_ENABLED=False
HAYSTACK_SEARCH=False
mattiagiupponi marked this conversation as resolved.
Show resolved Hide resolved
HAYSTACK_ENGINE_URL=http://elasticsearch:9200/
HAYSTACK_ENGINE_INDEX_NAME=haystack
HAYSTACK_SEARCH_RESULTS_PER_PAGE=200

# #################
# nginx
Expand All @@ -64,7 +68,7 @@ NGINX_BASE_URL=http://localhost
# port where the server can be reached on HTTPS
HTTP_HOST=localhost
HTTPS_HOST=

POSTGRESQL_MAX_CONNECTIONS=100
HTTP_PORT=8000
HTTPS_PORT=443

Expand Down Expand Up @@ -237,4 +241,4 @@ DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=100
MICROSOFT_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_SECRET_KEY=
AZURE_KEY=
AZURE_KEY=
18 changes: 9 additions & 9 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ services:
retries: 5
start_period: 30s

# Gets and installs letsencrypt certificates
letsencrypt:
image: geonode/letsencrypt:2.6.0-latest
container_name: letsencrypt4${COMPOSE_PROJECT_NAME}
env_file:
- .env_test
volumes:
- nginx-certificates:/geonode-certificates
restart: unless-stopped
# # Gets and installs letsencrypt certificates
# letsencrypt:
# image: geonode/letsencrypt:2.6.0-latest
# container_name: letsencrypt4${COMPOSE_PROJECT_NAME}
# env_file:
# - .env_test
# volumes:
# - nginx-certificates:/geonode-certificates
# restart: unless-stopped

# Geoserver backend
geoserver:
Expand Down
2 changes: 1 addition & 1 deletion geonode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_version():
return geonode.version.get_version(__version__)


def main(global_settings, **settings):
def main(_, **settings):
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings.get("django_settings"))
Expand Down
21 changes: 20 additions & 1 deletion geonode/assets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,26 @@ def test_download_file(self):
u, _ = get_user_model().objects.get_or_create(username="admin")
self.assertTrue(self.client.login(username="admin", password="admin"), "Login failed")

asset = self._setup_test(u)
asset_handler = asset_handler_registry.get_default_handler()
asset = asset_handler.create(
title="Test Asset",
description="Description of test asset",
type="NeverMind",
owner=u,
files=[ONE_JSON],
clone_files=True,
)
asset.save()
self.assertIsInstance(asset, LocalAsset)

reloaded = Asset.objects.get(pk=asset.pk)

# put two more files in the asset dir
asset_dir = os.path.dirname(reloaded.location[0])
sub_dir = os.path.join(asset_dir, "subdir")
os.mkdir(sub_dir)
shutil.copy(TWO_JSON, asset_dir)
shutil.copy(THREE_JSON, sub_dir)

for path, key in ((None, "one"), ("one.json", "one"), ("two.json", "two"), ("subdir/three.json", "three")):
# args = [asset.pk, path] if path else [asset.pk]
Expand Down
6 changes: 0 additions & 6 deletions geonode/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,3 @@ def register_event(request, event_type, resource):
raise ValueError(f"Invalid resource: {resource}")
if request and hasattr(request, "register_event"):
request.register_event(event_type, resource_type, resource_name, resource_id)


def register_proxy_event(request):
"""
Process request to geoserver proxy. Extract layer and ows type
"""
16 changes: 4 additions & 12 deletions geonode/base/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,17 +2408,9 @@ def test_resource_service_copy_with_perms_doc(self):

@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
def test_resource_service_copy_with_perms_map(self):
files = os.path.join(gisdata.GOOD_DATA, "vector/single_point.shp")
files_as_dict, _ = get_files(files)
resource = Document.objects.create(
owner=get_user_model().objects.get(username="admin"),
alternate="geonode:test_copy",
resource_type="map",
uuid=str(uuid4()),
)
_, _ = create_asset_and_link(
resource, get_user_model().objects.get(username="admin"), list(files_as_dict.values())
)

resource = create_single_map(name="test_copy")

self._assertCloningWithPerms(resource)

def _assertCloningWithPerms(self, resource):
Expand All @@ -2430,7 +2422,7 @@ def _assertCloningWithPerms(self, resource):
resource.set_permissions(_perms)
copy_url = reverse("importer_resource_copy", kwargs={"pk": resource.pk})
response = self.client.put(copy_url, data={"title": "cloned_resource"})
self.assertIn(response.status_code, [403, 404])
self.assertIn(response.status_code, [302, 403, 404])
# set perms to enable user clone resource
# bobby can copy the resource since he has all the perms needed
_perms = {
Expand Down
17 changes: 0 additions & 17 deletions geonode/base/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,6 @@ def extract_user_from_headers(request):
return user


def extract_headers(request):
"""
Extracts headers from the Django request object
:param request: The current django.http.HttpRequest object
:return: a dictionary with OAuthLib needed headers
"""
headers = request.META.copy()
if "wsgi.input" in headers:
del headers["wsgi.input"]
if "wsgi.errors" in headers:
del headers["wsgi.errors"]
if "HTTP_AUTHORIZATION" in headers:
headers["Authorization"] = headers["HTTP_AUTHORIZATION"]

return headers


def make_token_expiration(seconds=86400):
_expire_seconds = getattr(settings, "ACCESS_TOKEN_EXPIRE_SECONDS", seconds)
_expire_time = datetime.datetime.now(timezone.get_current_timezone())
Expand Down
7 changes: 0 additions & 7 deletions geonode/base/bbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ def as_polygon(self):
return DjangoPolygon.from_bbox((self.xmin, self.ymin, self.xmax, self.ymax))


def normalize_x_value(value):
"""
Normalise x-axis value/longtitude to fall within [-180, 180]
"""
return ((value + 180) % 360) - 180


def polygon_from_bbox(bbox, srid=4326):
"""
Constructs a Polygon object with srid from a provided bbox.
Expand Down
17 changes: 0 additions & 17 deletions geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core import validators
from django.db.models import Prefetch, Q
from django.forms import models
from django.forms.fields import ChoiceField, MultipleChoiceField
Expand Down Expand Up @@ -659,22 +658,6 @@ class Meta:
)


class ValuesListField(forms.Field):
def to_python(self, value):
if value in validators.EMPTY_VALUES:
return []

value = [item.strip() for item in value.split(",") if item.strip()]

return value

def clean(self, value):
value = self.to_python(value)
self.validate(value)
self.run_validators(value)
return value


class BatchEditForm(forms.Form):
LANGUAGES = (("", "--------"),) + ALL_LANGUAGES
group = forms.ModelChoiceField(label=_("Group"), queryset=Group.objects.all(), required=False)
Expand Down
9 changes: 0 additions & 9 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,15 +617,6 @@ def cleanup_uploaded_files(resource_id):
filename = f"{_resource.get_real_instance().resource_type}-{_resource.get_real_instance().uuid}"
remove_thumbs(filename)

# Remove the uploaded sessions, if any
if "geonode.upload" in settings.INSTALLED_APPS:
from geonode.upload.models import Upload

# Need to call delete one by one in order to invoke the
# 'delete' overridden method
for upload in Upload.objects.filter(resource_id=_resource.get_real_instance().id):
upload.delete()


class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
"""
Expand Down
10 changes: 0 additions & 10 deletions geonode/catalogue/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,6 @@ def fst(value):
return result


# from a resource object, build the corresponding metadata dict
# the aim is to handle the output format (csv, html or pdf) the same structure
def build_md_dict(resource):
md_dict = {
"r_uuid": {"label": "uuid", "value": resource.uuid},
"r_title": {"label": "titre", "value": resource.title},
}
return md_dict


def get_keywords(resource):
content = " "
cursor = connection.cursor()
Expand Down
8 changes: 0 additions & 8 deletions geonode/client/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ def load_path_attr(path):
return attr


def is_installed(package):
try:
__import__(package)
return True
except ImportError:
return False


class GeoNodeClientAppConf(AppConf):
LAYER_PREVIEW_LIBRARY = "geonode"
HOOKSET = "geonode.client.hooksets.BaseHookSet"
Expand Down
41 changes: 0 additions & 41 deletions geonode/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,6 @@ def view_or_apiauth(view, request, test_func, *args, **kwargs):
return response


def has_perm_or_basicauth(perm, realm=""):
"""
This is similar to the above decorator 'logged_in_or_basicauth'
except that it requires the logged in user to have a specific
permission.

Use:

@logged_in_or_basicauth('asforums.view_forumcollection')
def your_view:
...

"""

def view_decorator(func):
def wrapper(request, *args, **kwargs):
return view_or_basicauth(func, request, lambda u: u.has_perm(perm), realm, *args, **kwargs)

return wrapper

return view_decorator


def superuser_only(function):
"""
Limit view to superusers only.
Expand Down Expand Up @@ -289,16 +266,6 @@ def wrapper(request, *args, **kwargs):
return view_decorator


def logged_in_or_apiauth():
def view_decorator(func):
def wrapper(request, *args, **kwargs):
return view_or_apiauth(func, request, lambda u: u.is_authenticated, *args, **kwargs)

return wrapper

return view_decorator


def superuser_or_apiauth():
def view_decorator(func):
def wrapper(request, *args, **kwargs):
Expand All @@ -307,11 +274,3 @@ def wrapper(request, *args, **kwargs):
return wrapper

return view_decorator


def dump_func_name(func):
def echo_func(*func_args, **func_kwargs):
logger.debug(f"Start func: {func.__name__}")
return func(*func_args, **func_kwargs)

return echo_func
6 changes: 0 additions & 6 deletions geonode/documents/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ class Meta(ResourceBaseForm.Meta):
)


class DocumentDescriptionForm(forms.Form):
title = forms.CharField(max_length=300)
abstract = forms.CharField(max_length=2000, widget=forms.Textarea, required=False)
keywords = forms.CharField(max_length=500, required=False)


class DocumentCreateForm(TranslationModelForm):
"""
The document upload form.
Expand Down
Loading
Loading