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

changes needed for several dependencies for Debian Bookworm #114

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7ca259c
django changes: urlresolvers module was moved to django.urls
megies Jun 27, 2023
b84914e
django changes: ForeignKey on_delete is now mandatory argument
megies Jun 27, 2023
3801465
django update: GeoManager was removed
megies Jun 27, 2023
1585316
django update: include() helper in urls module changed syntax
megies Jun 27, 2023
46898e4
django rest framework change: some decorators got combined in a new o…
megies Jun 27, 2023
d432beb
django rest framework change: minor change in API
megies Jun 27, 2023
3cb3995
django update: try to adjust to middleware changes
megies Jun 27, 2023
ca80088
django changes: validators need to be specified as objects
megies Jun 29, 2023
2d7b970
django update: specify DEFAULT_AUTO_FIELD in settings
megies Jun 29, 2023
1db003d
django update: JSONField from contrib is deprecated
megies Jun 29, 2023
c4b59f6
django changes: many-to-many direct assignment not allowed anymore
megies Jun 29, 2023
b7c5a32
django changes: user.is_authenticated() method removed
megies Jun 29, 2023
24efb45
django changes: {% load staticfiles %} was removed
megies Jun 29, 2023
986b07e
mkdocs update: adjust config yaml to some config syntax changes
megies Jun 29, 2023
74d0347
add logging to file and and option to set a custom logfile in local_s…
megies Apr 11, 2024
4be05ef
GIS: remove Stamen layers, make OpenTopoMap default
megies Nov 8, 2023
d71a905
webgis: reduce default opacity
megies Apr 11, 2024
e5af798
geopy/postgis: adjust to API changes
megies Jun 28, 2024
17b3496
webgis html: remove a superfluous closing tag
megies Jun 28, 2024
462b6bb
add new migration
megies Oct 25, 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
5 changes: 3 additions & 2 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
site_name: Jane
repo_url: https://github.com/krischer/jane/
use_directory_urls: false
theme: cosmo
theme:
name: mkdocs
copyright: Jane Developers, 2014-2016
pages:
nav:
- 'Home': 'index.md'
- 'Introduction': 'introduction.md'
- 'Details':
Expand Down
2 changes: 1 addition & 1 deletion src/jane/documents/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from django.conf.urls import url
from django.contrib.gis import admin
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.urls import reverse

from jane.documents import models

Expand Down
18 changes: 9 additions & 9 deletions src/jane/documents/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from django.conf import settings
import django.contrib.gis.db.models.fields
from django.contrib.postgres.fields import jsonb
from django.db import models, migrations
from django.db.models import JSONField
import djangoplugins.fields


Expand All @@ -27,7 +27,7 @@ class Migration(migrations.Migration):
('sha1', models.CharField(unique=True, db_index=True, max_length=40, editable=False)),
('created_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('created_by', models.ForeignKey(related_name='documents_created', to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(related_name='documents_created', on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Document',
Expand All @@ -39,9 +39,9 @@ class Migration(migrations.Migration):
name='DocumentIndex',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
('json', jsonb.JSONField(verbose_name='JSON')),
('json', JSONField(verbose_name='JSON')),
('geometry', django.contrib.gis.db.models.fields.GeometryCollectionField(srid=4326, geography=True, blank=True, null=True)),
('document', models.ForeignKey(related_name='indices', to='documents.Document')),
('document', models.ForeignKey(related_name='indices', to='documents.Document', on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Index',
Expand All @@ -58,9 +58,9 @@ class Migration(migrations.Migration):
('data', models.BinaryField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('created_by', models.ForeignKey(related_name='attachments_created', to=settings.AUTH_USER_MODEL)),
('index', models.ForeignKey(related_name='attachments', to='documents.DocumentIndex')),
('modified_by', models.ForeignKey(related_name='attachments_modified', to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(related_name='attachments_created', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('index', models.ForeignKey(related_name='attachments', to='documents.DocumentIndex', on_delete=models.CASCADE)),
('modified_by', models.ForeignKey(related_name='attachments_modified', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Attachment',
Expand All @@ -87,12 +87,12 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='document',
name='document_type',
field=models.ForeignKey(related_name='documents', to='documents.DocumentType'),
field=models.ForeignKey(related_name='documents', to='documents.DocumentType', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='document',
name='modified_by',
field=models.ForeignKey(related_name='documents_modified', to=settings.AUTH_USER_MODEL),
field=models.ForeignKey(related_name='documents_modified', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
),
migrations.AlterUniqueTogether(
name='document',
Expand Down
41 changes: 41 additions & 0 deletions src/jane/documents/migrations/0003_auto_20241025_1136.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 3.2.19 on 2024-10-25 11:36

from django.db import migrations
import django.db.models.deletion
import djangoplugins.fields


class Migration(migrations.Migration):

dependencies = [
('djangoplugins', '0002_add_id_to_plugins_uniq'),
('documents', '0002_auto_20161018_0646'),
]

operations = [
migrations.AlterField(
model_name='documenttype',
name='definition',
field=djangoplugins.fields.PluginField(limit_choices_to={'point__pythonpath': 'jane.documents.plugins.DocumentPluginPoint'}, on_delete=django.db.models.deletion.CASCADE, related_name='definition', to='djangoplugins.plugin'),
),
migrations.AlterField(
model_name='documenttype',
name='indexer',
field=djangoplugins.fields.PluginField(limit_choices_to={'point__pythonpath': 'jane.documents.plugins.IndexerPluginPoint'}, on_delete=django.db.models.deletion.CASCADE, related_name='indexer', to='djangoplugins.plugin'),
),
migrations.AlterField(
model_name='documenttype',
name='retrieve_permissions',
field=djangoplugins.fields.ManyPluginField(blank=True, limit_choices_to={'point__pythonpath': 'jane.documents.plugins.RetrievePermissionPluginPoint'}, related_name='retrieve_permissions', to='djangoplugins.Plugin'),
),
migrations.AlterField(
model_name='documenttype',
name='upload_permissions',
field=djangoplugins.fields.ManyPluginField(blank=True, limit_choices_to={'point__pythonpath': 'jane.documents.plugins.UploadPermissionPluginPoint'}, related_name='upload_permissions', to='djangoplugins.Plugin'),
),
migrations.AlterField(
model_name='documenttype',
name='validators',
field=djangoplugins.fields.ManyPluginField(blank=True, limit_choices_to={'point__pythonpath': 'jane.documents.plugins.ValidatorPluginPoint'}, related_name='validators', to='djangoplugins.Plugin'),
),
]
29 changes: 18 additions & 11 deletions src/jane/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
from django.contrib.auth.models import AnonymousUser
from django.contrib.gis.db import models
from django.contrib.gis.measure import Distance
from django.contrib.postgres.fields import jsonb
from django.core.urlresolvers import reverse
from django.db import connection
from django.db.models import JSONField
from django.db.models.aggregates import Count
from django.db.models.expressions import OrderBy, RawSQL
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template.defaultfilters import filesizeformat
from django.urls import reverse
from djangoplugins.fields import PluginField, ManyPluginField
from obspy.core.utcdatetime import UTCDateTime
from rest_framework import status
Expand Down Expand Up @@ -171,7 +171,8 @@ class Document(models.Model):
any type that is described by indices.
"""
# The type of the document. Depends on the available Jane plug-ins.
document_type = models.ForeignKey(DocumentType, related_name='documents')
document_type = models.ForeignKey(DocumentType, related_name='documents',
on_delete=models.CASCADE)
# The name of that particular document. Oftentimes the filename. Unique
# together with the document type to enable a nice REST API.
name = models.CharField(max_length=255, db_index=True)
Expand All @@ -189,9 +190,11 @@ class Document(models.Model):
modified_at = models.DateTimeField(auto_now=True, editable=False)
# Users responsible for the aforementioned actions.
created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
related_name='documents_created')
related_name='documents_created',
on_delete=models.CASCADE)
modified_by = models.ForeignKey(settings.AUTH_USER_MODEL,
related_name='documents_modified')
related_name='documents_modified',
on_delete=models.CASCADE)
objects = DocumentManager()

class Meta:
Expand Down Expand Up @@ -228,7 +231,7 @@ def save(self, *args, **kwargs):
signals.index_document(sender=None, instance=self, created=None)


class DocumentIndexManager(models.GeoManager):
class DocumentIndexManager(models.Manager):
"""
Custom queryset manager for the document indices.
"""
Expand Down Expand Up @@ -504,8 +507,9 @@ class DocumentIndex(models.Model):
"""
Indexed values for a specific document.
"""
document = models.ForeignKey(Document, related_name='indices')
json = jsonb.JSONField(verbose_name="JSON")
document = models.ForeignKey(Document, related_name='indices',
on_delete=models.CASCADE)
json = JSONField(verbose_name="JSON")
geometry = models.GeometryCollectionField(blank=True, null=True,
geography=True)

Expand Down Expand Up @@ -653,7 +657,8 @@ class DocumentIndexAttachment(models.Model):
"""
Attachments for one Document.
"""
index = models.ForeignKey(DocumentIndex, related_name='attachments')
index = models.ForeignKey(DocumentIndex, related_name='attachments',
on_delete=models.CASCADE)
category = models.CharField(max_length=50, db_index=True)
content_type = models.CharField(max_length=255)
data = models.BinaryField()
Expand All @@ -663,9 +668,11 @@ class DocumentIndexAttachment(models.Model):
modified_at = models.DateTimeField(auto_now=True, editable=False)
# Users responsible for the aforementioned actions.
created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
related_name='attachments_created')
related_name='attachments_created',
on_delete=models.CASCADE)
modified_by = models.ForeignKey(settings.AUTH_USER_MODEL,
related_name='attachments_modified')
related_name='attachments_modified',
on_delete=models.CASCADE)
objects = DocumentIndexAttachmentManager()

class Meta:
Expand Down
6 changes: 3 additions & 3 deletions src/jane/documents/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def initialize_plugins():
indexer=indexer)
resource_type.save()

resource_type.validators = validators
resource_type.retrieve_permissions = retrieve_permissions
resource_type.upload_permissions = upload_permissions
resource_type.validators.set(validators)
resource_type.retrieve_permissions.set(retrieve_permissions)
resource_type.upload_permissions.set(upload_permissions)
resource_type.save()

# Permissions.
Expand Down
6 changes: 3 additions & 3 deletions src/jane/documents/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
router = OptionalTrailingSlashSimpleRouter(trailing_slash=False)
router.register(prefix='documents/(?P<document_type>[a-zA-Z0-9]+)',
viewset=views.DocumentsView,
base_name="rest_documents")
basename="rest_documents")
router.register(prefix='document_indices/(?P<document_type>[a-zA-Z0-9]+)',
viewset=views.DocumentIndicesView,
base_name="rest_document_indices")
basename="rest_document_indices")
router.register(
prefix=('document_indices/(?P<document_type>[a-zA-Z0-9]+)/(?P<idx>[0-9]+)'
'/attachments'),
viewset=views.DocumentIndexAttachmentsView,
base_name="rest_document_index_attachments")
basename="rest_document_index_attachments")
urlpatterns.append(url(r'^rest/', include(router.urls)))


Expand Down
2 changes: 1 addition & 1 deletion src/jane/fdsnws/views/dataselect_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def query(request):
return _error(request, msg)
longestonly = bool(longestonly)
# user
if request.user.is_authenticated():
if request.user.is_authenticated:
user = request.user
else:
user = None
Expand Down
2 changes: 1 addition & 1 deletion src/jane/fdsnws/views/station_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def query(request):
url = request.build_absolute_uri(request.get_full_path())

# user
if request.user.is_authenticated():
if request.user.is_authenticated:
user = request.user
else:
user = None
Expand Down
2 changes: 1 addition & 1 deletion src/jane/jane/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def your_view:
def view_decorator(func):
def wrapper(request, *args, **kwargs):
return view_or_basicauth(func, request,
lambda u: u.is_authenticated(),
lambda u: u.is_authenticated,
realm, *args, **kwargs)
return wrapper
return view_decorator
Expand Down
47 changes: 27 additions & 20 deletions src/jane/jane/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@


class AutoLogoutMiddleware(object):
def process_request(self, request):
# can't log out if not logged in
if not request.user.is_authenticated():
return
def __init__(self, get_response):
self.get_response = get_response

# check if auto logout is activated
try:
if not settings.AUTO_LOGOUT_MINUTES:
return
except:
return
def __call__(self, request):
set_last_touch = True

try:
delta = time.time() - request.session['last_touch']
except (KeyError, TypeError):
pass
# can't log out if not logged in
if not request.user.is_authenticated:
# do nothing
set_last_touch = False
# check if auto logout is activated
elif not settings.AUTO_LOGOUT_MINUTES:
# do nothing
set_last_touch = False
else:
seconds = settings.AUTO_LOGOUT_MINUTES * 60
if delta > seconds:
del request.session['last_touch']
auth.logout(request)
return
try:
delta = time.time() - request.session['last_touch']
except (KeyError, TypeError):
pass
else:
seconds = settings.AUTO_LOGOUT_MINUTES * 60
if delta > seconds:
del request.session['last_touch']
auth.logout(request)
set_last_touch = False

if set_last_touch:
request.session['last_touch'] = time.time()

request.session['last_touch'] = time.time()
response = self.get_response(request)
return response
2 changes: 1 addition & 1 deletion src/jane/jane/templates/jane/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}<!DOCTYPE html>
{% load static %}<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
Expand Down
2 changes: 2 additions & 0 deletions src/jane/local_settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ JANE_ACCENT_COLOR = "#D9230F"
JANE_FDSN_STATIONXML_SENDER = "Jane"
JANE_FDSN_STATIONXML_SOURCE = "Jane"

# optionally set a custom logfile destination, overriding the default value from settings.py
#LOGFILE = '/home/sysop/logs/jane-rotational.log'

# Change the settings for the test database here!
# for pytest-django, this did not work for me:
Expand Down
2 changes: 1 addition & 1 deletion src/jane/quakeml/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def index(self, document):
(horizontal_uncertainty_min,
horizontal_uncertainty_max_azimuth + 90)):
azimuth = azimuth % 180
distance = geopy.distance.VincentyDistance(
distance = geopy.distance.geodesic(
kilometers=distance / 1e3)
end1 = distance.destination(
point=start, bearing=azimuth)
Expand Down
Loading