Giter VIP home page Giter VIP logo

djangocms-url-manager's Introduction

django CMS URL Manager

Installation

Requirements

django CMS URL Manager requires that you have a django CMS 4.0 or higher project already set up and running.

For those who wish to use this app on Django <3.2 or Python <3.8 use the 4.0.x branch.

To install

Run:

pip install djangocms-url-manager

Add djangocms_url_manager to your project's INSTALLED_APPS.

Run:

python manage.py migrate djangocms_url_manager

to perform the application's database migrations.

Usage

Migration 0008 requires the use of a user in order to create versions for existing urls (if djangocms_versioning is installed and enabled), a user can be chosen with the setting DJANGOCMS_URL_MANAGER_VERSIONING_MIGRATION_USER_ID, the default is 1.

DJANGOCMS_URL_MANAGER_VERSIONING_MIGRATION_USER_ID = 2 # Will use user with id: 2

djangocms-url-manager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

djangocms-url-manager's Issues

Apparent race condition: Admin form for link plugin does not display url select2 box

Setup:

Result: Only roughly 50% of the time an error is thrown

  • The url field renders as TextInput.
  • Console says query function not defined for Select2 s2id_id_site
  • If in edit mode, a number appears in the text input field

image

Since this sometimes a server restart, a clearing of the browser cache helps, I fear it is some kind of race condition. Which prevents the two select2 fields to link.

A potential solution might be to catch the error and retry after a delay if the error is due to parts of the site / scripts not yet fully loaded.

Issue passing params to content type view

I can't see that there's an issue in my setup here, but the ajax call to ContentTypeObjectSelect2View isn't getting a content_id or site value.

The JS is doing the show/hide depending on the type selection, but on the "Page" selection, the content lookup isn't able to get a value from the two fields.

Screenshot 2022-02-18 at 22 38 22

Looking through the dev tools, I would expect select2 to change the selected attr on the hidden select boxes when I change the value, but that stays at the initial. Not just for the url type, but for site also. It's been a few years since I've used select2 though, so I'm not making educated guesses here!

Conflict between django 1.11 support and versioning moving beyond 1.11

The base requirements for tests installs versioning, however versioning has dropped support for django 1.11. Specifically with it's use of django 2 url paths.

Django 1.11 either needs to be dropped or the requirements for it need to install an earlier version of versioning.

Error seen in workflows;

 File "/home/runner/work/djangocms-url-manager/djangocms-url-manager/djangocms_url_manager/admin.py", line 3, in <module>
    from djangocms_url_manager.cms_config import UrlCMSAppConfig
  File "/home/runner/work/djangocms-url-manager/djangocms-url-manager/djangocms_url_manager/cms_config.py", line 99, in <module>
    class UrlCMSAppConfig(CMSAppConfig):
  File "/home/runner/work/djangocms-url-manager/djangocms-url-manager/djangocms_url_manager/cms_config.py", line 121, in UrlCMSAppConfig
    from djangocms_versioning.datastructures import VersionableItem, default_copy
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/djangocms_versioning/datastructures.py", line 8, in <module>
    from .admin import VersioningAdminMixin
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/djangocms_versioning/admin.py", line 13, in <module>
    from django.urls import re_path, reverse
ImportError: cannot import name 're_path'

Updating model URLs broken

When updating a model it is not possible to change the type of URL. i.e. if a saved model instance is linked to a page it is not possible to change to a manual URL. - if this is an intended feature there should be feedback.

Issue initialising Select2

I've got an issue where the select2 elements aren't being initialised.

At first I thought it's an issue with the dom not being ready, because from the console I can switch the elements to select2 just like the app JS does.

Then I swapped the jquery being used from CMS.$, to django.jQuery and it just works.

Screenshot 2022-02-18 at 19 33 04

Screenshot 2022-02-18 at 19 33 45

Packages I'm using;

django>=3.2,<4.0
-e git://github.com/django-cms/django-cms.git@develop-4#egg=django-cms
-e git://github.com/Aiky30/djangocms-url-manager.git@feature/django-32-compat#egg=djangocms-url-manager
https://github.com/django-cms/djangocms-versioning/tarball/master#egg=djangocms-versioning
-e git://github.com/django-cms/djangocms-text-ckeditor.git@support/4.0.x#egg=djangocms-text-ckeditor
-e git://github.com/FidelityInternational/[email protected]#egg=djangocms-pageadmin
-e git://github.com/FidelityInternational/djangocms-version-locking.git@master#egg=djangocms-version-locking

Missing content type during initial migration

Just adding cms 4 to an existing django project I've hit an error in migration 8.

So I've added the following apps, none of which have a presence in the database yet;

    'cms.apps.CMSConfig',
    'djangocms_pageadmin.apps.PageAdminConfig',
    'djangocms_url_manager.apps.UrlManagerConfig',
    'djangocms_text_ckeditor.apps.TextCkeditorConfig',
    'djangocms_versioning.apps.VersioningConfig',
    'djangocms_version_locking.apps.VersionLockingConfig',
    'menus.apps.MenusConfig',
    'treebeard',
(.venv) % python manage.py migrate
Operations to perform:
  Apply all migrations: account, accounts, admin, admin_interface, administration, auth, authentication, base, charity, clients, cms, comms, console, contenttypes, djangocms_text_ckeditor, djangocms_url_manager, djangocms_version_locking, djangocms_versioning, entry, event, explorer, faq, flatpages, gdpr_cookie_consent, imageuploader, location, menus, otp_totp, payment, redirects, sessions, shop, sites, socialaccount
Running migrations:
  Applying cms.0001_initial... OK
  Applying cms.0002_auto_20140816_1918... OK
  Applying cms.0003_auto_20140926_2347... OK
  Applying cms.0004_auto_20140924_1038... OK
  Applying cms.0005_auto_20140924_1039... OK
  Applying cms.0006_auto_20140924_1110... OK
  Applying cms.0007_auto_20141028_1559... OK
  Applying cms.0008_auto_20150208_2149... OK
  Applying cms.0008_auto_20150121_0059... OK
  Applying cms.0009_merge... OK
  Applying cms.0010_migrate_use_structure... OK
  Applying cms.0011_auto_20150419_1006... OK
  Applying cms.0012_auto_20150607_2207... OK
  Applying cms.0013_urlconfrevision... OK
  Applying cms.0014_auto_20160404_1908... OK
  Applying cms.0015_auto_20160421_0000... OK
  Applying cms.0016_auto_20160608_1535... OK
  Applying cms.0017_pagetype... OK
  Applying cms.0018_create_pagenode... OK
  Applying cms.0019_set_pagenode... OK
  Applying cms.0020_old_tree_cleanup... OK
  Applying cms.0021_auto_20180507_1432... OK
  Applying cms.0022_auto_20180620_1551... OK
  Applying cms.0023_placeholder_source_field... OK
  Applying cms.0024_set_plugin_absolute_position... OK
  Applying cms.0025_remove_plugin_tree_fields... OK
  Applying cms.0026_title_placeholders... OK
  Applying cms.0027_title_placeholders_data_migration... OK
  Applying cms.0028_remove_page_placeholders... OK
  Applying cms.0029_create_title_fields_and_url_model... OK
  Applying cms.0030_auto_20180810_0629... OK
  Applying cms.0031_remove_fields... OK
  Applying cms.0032_remove_title_to_pagecontent... OK
  Applying cms.0033_placeholder_source_data_migration... OK
  Applying cms.0034_remove_pagecontent_placeholders... OK
  Applying djangocms_text_ckeditor.0001_initial... OK
  Applying djangocms_text_ckeditor.0002_remove_related_name_for_cmsplugin_ptr... OK
  Applying djangocms_text_ckeditor.0003_set_related_name_for_cmsplugin_ptr... OK
  Applying djangocms_text_ckeditor.0004_auto_20160706_1339... OK
  Applying djangocms_url_manager.0001_initial... OK
  Applying djangocms_url_manager.0002_auto_20190218_1639... OK
  Applying djangocms_url_manager.0003_auto_20190524_0456... OK
  Applying djangocms_url_manager.0004_auto_20200114_0829... OK
  Applying djangocms_url_manager.0005_auto_20200923_0843... OK
  Applying djangocms_url_manager.0006_auto_20210513_1359... OK
  Applying djangocms_url_manager.0007_auto_20211124_0408... OK
  Applying djangocms_url_manager.0008_url_manager_data_migration...Traceback (most recent call last):
  File "/Users/mwalker/Sites/consoles/manage.py", line 34, in <module>
    main()
  File "/Users/mwalker/Sites/consoles/manage.py", line 30, in main
    execute_from_command_line(sys.argv)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/Users/mwalker/Sites/consoles/.venv/src/djangocms-url-manager/djangocms_url_manager/migrations/0008_url_manager_data_migration.py", line 25, in forwards
    url_contenttype = ContentType.objects.get(app_label='djangocms_url_manager', model='url')
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/mwalker/Sites/consoles/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
__fake__.DoesNotExist: ContentType matching query does not exist.

At that point of failure, the content types that exist related to cms are;

Screenshot 2022-02-17 at 12 14 39

So I think the forwards() on migration 8 needs an early exit to account for a new install that doesn't have any content to create versions for.

Config needs to handle versioning and moderation too

The url manager has an option of using djangocms-navigation. As djangocms-navigation also supports versioning and moderation the url manager should be able to handle these options as well.

Currently the pattern seems to be DJANGOCMS_NAVIGATION_CMS_MODELS_ENABLED since this relates to the url manager I think it would be more appropriate to have the setting to be DJANGOCMS_URL_MANAGER_NAVIGATION_ENABLED.

The same would go for versioning moderation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.