diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py index 46b070449c3bc6ff46e98ace323953b7f6252ac1..98e239d30e4e37245bb20285bd56e3768385c92b 100644 --- a/aleksis/core/settings.py +++ b/aleksis/core/settings.py @@ -60,6 +60,7 @@ INSTALLED_APPS = [ "django_any_js", "django_yarnpkg", "django_tables2", + "include_by_ajax", "easy_thumbnails", "image_cropping", "maintenance_mode", diff --git a/aleksis/core/templates/core/index.html b/aleksis/core/templates/core/index.html index 5fcd8a64d8eda5ad401debb776a80264ff29ef65..0d26fe51e8a81a42a40525c88264e9d93ff4f5c3 100644 --- a/aleksis/core/templates/core/index.html +++ b/aleksis/core/templates/core/index.html @@ -1,5 +1,5 @@ {% extends 'core/base.html' %} -{% load i18n %} +{% load i18n static include_by_ajax_tags %} {% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %} @@ -19,19 +19,22 @@ </a> </div> - <strong>{{ notification.title }}</strong> - <p>{{ notification.description }}</p> - </div> - </div> - {% endfor %} - - <div class="row"> - {% for widget in widgets %} - <div class="col s12 m12 l6 xl4"> - {{ widget }} + <strong>{{ notification.title }}</strong> + <p>{{ notification.description }}</p> + </div> </div> {% endfor %} - </div> + + <div class="row"> + {% for widget in widgets %} + <div class="col s12 m12 l6 xl4"> +{# {{ widget }}#} + {% with widget.1 as d_widget %} + {% include_by_ajax "dashboardfeeds/rss.html" %} + {% endwith %} + </div> + {% endfor %} + </div> <div class="row"> <div class="col s12 m6"> @@ -88,6 +91,7 @@ {% endif %} </div> + <script src="{% static 'include_by_ajax/js/include_by_ajax.min.js' %}" defer></script> <script type="text/javascript"> const asyncIntervals = []; @@ -130,12 +134,16 @@ let dashboard_interval = setAsyncInterval(async () => { console.log('fetching new data'); const promise = new Promise((resolve) => { - $('#dashboard').load("/ #dashboard"); + $('#dashboard').load("/?include_by_ajax_full_render=1 #dashboard"); resolve(1); }); await promise; console.log('data fetched successfully'); }, 15000); + $(document).on('include_by_ajax_all_loaded', function() { + console.log('Now all placeholders are loaded and replaced with content'); + }) + </script> {% endblock %} diff --git a/poetry.lock b/poetry.lock index b79635ec5cb6b28ed8ef904f8eb2d6894426aa80..2d92962b0f92da11278681156c12a87016b23ab7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -409,11 +409,6 @@ optional = false python-versions = "*" version = "2.5.0" -[package.dependencies] -[package.dependencies.django-picklefield] -optional = true -version = "*" - [package.extras] database = ["django-picklefield"] redis = ["redis"] @@ -422,6 +417,7 @@ redis = ["redis"] reference = "590fa02eb30e377da0eda5cc3a84254b839176a7" type = "git" url = "https://github.com/jazzband/django-constance" + [[package]] category = "main" description = "A configurable set of panels that display various debug information about the current request/response." @@ -501,6 +497,17 @@ optional = false python-versions = "*" version = "1.4.1" +[[package]] +category = "main" +description = "A Django App Providing the `{% include_by_ajax %}` Template Tag" +name = "django-include-by-ajax" +optional = false +python-versions = "*" +version = "2.0.0" + +[package.dependencies] +Django = ">=1.8" + [[package]] category = "main" description = "A Django utility application that returns client's real IP address" @@ -2009,7 +2016,7 @@ celery = ["Celery", "django-celery-results", "django-celery-beat", "django-celer ldap = ["django-auth-ldap"] [metadata] -content-hash = "0ce6ddf6659ad591ee689645d75ebead448cc5cafca3ff0c06d76be6b255802b" +content-hash = "200c59b4623fdac33a7c5f63a9df19b14ae1d7e46b22780f874e4edab9690243" python-versions = "^3.7" [metadata.files] @@ -2196,6 +2203,10 @@ django-image-cropping = [ django-impersonate = [ {file = "django-impersonate-1.4.1.tar.gz", hash = "sha256:63b62d06f93b0318698c68f7314c78473914c262d4164eb66ad860bb83e04771"}, ] +django-include-by-ajax = [ + {file = "django-include-by-ajax-2.0.0.tar.gz", hash = "sha256:d555439e9794fc6b04bc9c248a3d6ae60fe9231541dc73dc037ea8299cf630d6"}, + {file = "django_include_by_ajax-2.0.0-py2.py3-none-any.whl", hash = "sha256:5b3ea4086403ca01997e38fbe1bbfc7cb9180e640b8bb4269fac8524550c1928"}, +] django-ipware = [ {file = "django-ipware-2.1.0.tar.gz", hash = "sha256:a7c7a8fd019dbdc9c357e6e582f65034e897572fc79a7e467674efa8aef9d00b"}, ] diff --git a/pyproject.toml b/pyproject.toml index e69ab7a1ce657b496bc25f34bc73fddfa620226f..dae4bb6f7fc64926c7d82af2cae930a0ba68e632 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,7 @@ django-celery-beat = {version="^1.5.0", optional=true} django-celery-email = {version="^3.0.0", optional=true} django-jsonstore = "^0.4.1" ics = "^0.6" +django-include-by-ajax = "^2.0.0" [tool.poetry.extras] ldap = ["django-auth-ldap"]