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

fix compability issues with newer versions of django #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 23 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
CHANGELOG
=========

1.1.6 (2020-09-11)
------------------

* Fix leaking the `/admin` url when accessed without login


1.1.5 (2019-07-08)
------------------

* Remove python_2_unicode_compatible required for Django 2.2


1.1.4 (2019-04-29)
------------------

* Add 'on_delete=models.CASCADE' required for Django 2.0
* Fix unicode error in python 3
* Fix for 'query' field not used in model for Django 1.11


1.1.3 (2016-10-11)
------------------

* fix unicode error in location plugin
* fix error introduced in 1.1.2 (commit f76dedd7)
* Fix unicode error in location plugin
* Fix error introduced in 1.1.2 (commit f76dedd7)


1.1.2 (2016-10-11)
------------------

* path location plugin: fix absolute url
* Path location plugin: fix absolute url


1.1.1 (2016-09-14)
------------------

* fix staticmap with new kml location plugin
* Fix staticmap with new kml location plugin


1.1.0 (2016-09-14)
Expand Down
6 changes: 6 additions & 0 deletions aldryn_locations/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def render(self, context, instance, placeholder):
data = '{}{}'.format(base_url, data)
path_sources.append(data)
else:
if not request.toolbar or not (
getattr(request.toolbar, 'edit_mode')
or getattr(request.toolbar, 'edit_mode_active')
):
# do not leak /admin urls
data['admin'] = None
location_data.append(data)

# Options for the map comes from plugin so I assigned it here
Expand Down
15 changes: 8 additions & 7 deletions aldryn_locations/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand All @@ -14,7 +15,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='EmbedDirectionsPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('query', models.CharField(help_text='defines the place to highlight on the map. It accepts a location as either a place name or address', max_length=255, verbose_name='Query')),
('map_type', models.CharField(default='roadmap', max_length=300, verbose_name='Map Type', choices=[('roadmap', 'Roadmap'), ('satellite', 'Satellite')])),
('center', models.CharField(help_text='optionally define the center of the map view. It accepts a comma-separated latitude and longitude value (such as 37.4218,-122.0840).', max_length=255, null=True, verbose_name='Center of the map (latitude + longitude)', blank=True)),
Expand All @@ -38,7 +39,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='EmbedPlacePlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('query', models.CharField(help_text='defines the place to highlight on the map. It accepts a location as either a place name or address', max_length=255, verbose_name='Query')),
('map_type', models.CharField(default='roadmap', max_length=300, verbose_name='Map Type', choices=[('roadmap', 'Roadmap'), ('satellite', 'Satellite')])),
('center', models.CharField(help_text='optionally define the center of the map view. It accepts a comma-separated latitude and longitude value (such as 37.4218,-122.0840).', max_length=255, null=True, verbose_name='Center of the map (latitude + longitude)', blank=True)),
Expand All @@ -56,7 +57,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='EmbedSearchPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('query', models.CharField(help_text='defines the place to highlight on the map. It accepts a location as either a place name or address', max_length=255, verbose_name='Query')),
('map_type', models.CharField(default='roadmap', max_length=300, verbose_name='Map Type', choices=[('roadmap', 'Roadmap'), ('satellite', 'Satellite')])),
('center', models.CharField(help_text='optionally define the center of the map view. It accepts a comma-separated latitude and longitude value (such as 37.4218,-122.0840).', max_length=255, null=True, verbose_name='Center of the map (latitude + longitude)', blank=True)),
Expand All @@ -74,7 +75,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='EmbedViewPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('query', models.CharField(help_text='defines the place to highlight on the map. It accepts a location as either a place name or address', max_length=255, verbose_name='Query')),
('map_type', models.CharField(default='roadmap', max_length=300, verbose_name='Map Type', choices=[('roadmap', 'Roadmap'), ('satellite', 'Satellite')])),
('center', models.CharField(help_text='optionally define the center of the map view. It accepts a comma-separated latitude and longitude value (such as 37.4218,-122.0840).', max_length=255, null=True, verbose_name='Center of the map (latitude + longitude)', blank=True)),
Expand All @@ -92,7 +93,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='LocationPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('address', models.CharField(max_length=150, verbose_name='address')),
('zipcode', models.CharField(max_length=30, verbose_name='zip code')),
('city', models.CharField(max_length=100, verbose_name='city')),
Expand All @@ -108,7 +109,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='MapPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('title', models.CharField(max_length=100, null=True, verbose_name='map title', blank=True)),
('zoom', models.CharField(choices=[('0', '0'), ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10'), ('11', '11'), ('12', '12'), ('13', '13'), ('14', '14'), ('15', '15'), ('16', '16'), ('17', '17'), ('18', '18'), ('19', '19'), ('20', '20'), ('21', '21')], max_length=20, blank=True, help_text='Leave empty for auto zoom', null=True, verbose_name='Zoom level')),
('route_planner_title', models.CharField(default='Calculate your fastest way to here', max_length=150, null=True, verbose_name='Route Planner Title', blank=True)),
Expand All @@ -131,7 +132,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='RouteLocationPlugin',
fields=[
('locationplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='aldryn_locations.LocationPlugin', on_delete=models.CASCADE)),
('locationplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='aldryn_locations.LocationPlugin')),
],
options={
'abstract': False,
Expand Down
5 changes: 3 additions & 2 deletions aldryn_locations/migrations/0003_path file location.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import filer.fields.file


Expand All @@ -17,8 +18,8 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='PathLocationPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, related_name='aldryn_locations_pathlocationplugin', auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE)),
('path_file', filer.fields.file.FilerFileField(related_name='+', verbose_name='Path File (e.g. KML)', to='filer.File', on_delete=models.CASCADE)),
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_pathlocationplugin', auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('path_file', filer.fields.file.FilerFileField(on_delete=django.db.models.deletion.CASCADE, related_name='+', verbose_name='Path File (e.g. KML)', to='filer.File')),
],
options={
'abstract': False,
Expand Down
15 changes: 8 additions & 7 deletions aldryn_locations/migrations/0004_auto_20160914_1511.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand All @@ -14,36 +15,36 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='embeddirectionsplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_embeddirectionsplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_embeddirectionsplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='embedplaceplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_embedplaceplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_embedplaceplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='embedsearchplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_embedsearchplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_embedsearchplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='embedviewplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_embedviewplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_embedviewplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='locationplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_locationplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_locationplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='mapplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_mapplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_mapplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
migrations.AlterField(
model_name='pathlocationplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(parent_link=True, related_name='aldryn_locations_pathlocationplugin', primary_key=True, serialize=False, to='cms.CMSPlugin', on_delete=models.CASCADE),
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='aldryn_locations_pathlocationplugin', primary_key=True, serialize=False, to='cms.CMSPlugin'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 2.2.9 on 2020-06-23 18:56
import django.db.models.deletion
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
('cms', '0022_auto_20180620_1551'),
('aldryn_locations', '0005_auto_20180507_1427'),
]

operations = [
migrations.RenameModel(
old_name='RouteLocationPlugin',
new_name='RouteLocationPluginTemp',
),
migrations.CreateModel(
name='RouteLocationPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='aldryn_locations_routelocationplugin', serialize=False, to='cms.CMSPlugin')),
('address', models.CharField(max_length=255, verbose_name='address')),
('zipcode', models.CharField(max_length=30, verbose_name='zip code')),
('city', models.CharField(max_length=255, verbose_name='city')),
('content', models.CharField(blank=True, help_text='Displayed in a info window above location marker', max_length=255, verbose_name='Content')),
('lat', models.FloatField(blank=True, help_text='Use latitude & longitude to fine tune the map position.', null=True, verbose_name='latitude')),
('lng', models.FloatField(blank=True, null=True, verbose_name='longitude')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ def transfer_route_location_plugin_data(apps, schema_editor):
draft_page = page_with_old_plugin.get_draft_object()
draft_placeholder = draft_page.placeholders.get(slot=placeholder_with_old_plugin.slot)
draft_plugins = draft_placeholder.get_plugins()
draft_parent_map_plugins = list(
filter(
lambda x: (
x.get_bound_plugin().plugin_type == old_plugin.parent.get_bound_plugin().plugin_type and
x.get_bound_plugin().title == old_plugin.parent.get_bound_plugin().title and
_is_numchild_value_broken(x)
),
draft_plugins
old_plugin_parent_bound_plugin = old_plugin.parent.get_bound_plugin()

def filter_func(x):
try:
x_bound_plugin = x.get_bound_plugin()
except Exception as err:
print(err)
return False
return (
x_bound_plugin.plugin_type == old_plugin_parent_bound_plugin.plugin_type and
x_bound_plugin.title == old_plugin_parent_bound_plugin.title and
_is_numchild_value_broken(x)
)

draft_parent_map_plugins = list(
filter(filter_func, draft_plugins)
)

if draft_parent_map_plugins:
Expand Down Expand Up @@ -90,32 +97,9 @@ class Migration(migrations.Migration):

dependencies = [
('cms', '0022_auto_20180620_1551'),
('aldryn_locations', '0005_auto_20180507_1427'),
('aldryn_locations', '0006_fix_broken_routelocation_plugin_01'),
]

operations = [
migrations.RenameModel(
old_name='RouteLocationPlugin',
new_name='RouteLocationPluginTemp',
),
migrations.CreateModel(
name='RouteLocationPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='aldryn_locations_routelocationplugin', serialize=False, to='cms.CMSPlugin')),
('address', models.CharField(max_length=255, verbose_name='address')),
('zipcode', models.CharField(max_length=30, verbose_name='zip code')),
('city', models.CharField(max_length=255, verbose_name='city')),
('content', models.CharField(blank=True, help_text='Displayed in a info window above location marker', max_length=255, verbose_name='Content')),
('lat', models.FloatField(blank=True, help_text='Use latitude & longitude to fine tune the map position.', null=True, verbose_name='latitude')),
('lng', models.FloatField(blank=True, null=True, verbose_name='longitude')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
migrations.RunPython(transfer_route_location_plugin_data),
migrations.DeleteModel(
name='RouteLocationPluginTemp',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.9 on 2020-06-23 18:56
import django.db.models.deletion
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
('cms', '0022_auto_20180620_1551'),
('aldryn_locations', '0007_fix_broken_routelocation_plugin_02'),
]

operations = [
migrations.DeleteModel(
name='RouteLocationPluginTemp',
),
]
5 changes: 1 addition & 4 deletions aldryn_locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from cms.models import CMSPlugin, Site
from cms.utils.i18n import get_current_language
from cms.utils.compat.dj import python_2_unicode_compatible

from filer.fields.file import FilerFileField

Expand Down Expand Up @@ -37,7 +36,6 @@
]


@python_2_unicode_compatible
class MapPlugin(CMSPlugin):
cmsplugin_ptr = models.OneToOneField(
CMSPlugin,
Expand Down Expand Up @@ -158,7 +156,6 @@ def get_route_planner(self):
return False


@python_2_unicode_compatible
class LocationPlugin(CMSPlugin):
route_planner = False

Expand Down Expand Up @@ -286,7 +283,7 @@ class PathLocationPlugin(CMSPlugin):
CMSPlugin,
related_name='%(app_label)s_%(class)s',
parent_link=True,
on_delete=models.CASCADE
on_delete=models.CASCADE,
)

path_file = FilerFileField(
Expand Down