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

Timezone #231

Closed
wants to merge 17 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mptt/
venv/
.venv/
tagging/
build/
coverage
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ Francesco Facconi
Markus "mjtorn" Törnqvist
Remigiusz Dymecki
elky
Ju Sana
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.11
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
Expand Down
5 changes: 2 additions & 3 deletions example/blog/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.conf.urls import url
from blog import views
from django.urls import include, path, re_path

urlpatterns = [
url(r'^category/(?P<tag_id>[0-9]+)$', views.category_view, name='blog_category_view'),
url(r'^$', views.blog_index, name='blog_index')
re_path(r'^category/(?P<tag_id>[0-9]+)$', views.category_view, name='blog_category_view'),
re_path(r'^$', views.blog_index, name='blog_index')
]
2 changes: 2 additions & 0 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@

PAGE_USE_LANGUAGE_PREFIX = True

PAGE_AUTOMATIC_SLUG_RENAMING = True

# You should add here all language you want to accept as valid client
# language. By default we copy the PAGE_LANGUAGES constant and add some other
# similar languages.
Expand Down
2 changes: 1 addition & 1 deletion example/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h5 class="my-0 mr-md-0 font-weight-normal">
</h5>
<nav class="my-2 my-md-0 mr-md-3">
{% for page in pages_navigation %}
<a href="{% show_absolute_url page %}" class="p-2 text-dark{% ifequal page.id current_page.id %} font-weight-bolder{% endifequal %}">
<a href="{% show_absolute_url page %}" class="p-2 text-dark{% if page.id == current_page.id %} font-weight-bolder{% endif %}">
{% show_content page "title" %}
</a>
{% endfor %}
Expand Down
32 changes: 31 additions & 1 deletion example/templates/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,39 @@ <h3>Search results <span class="glyphicon glyphicon-search" aria-hidden="true"><

{% block content %}
<form method="get" action=".">

<table>
{{ form.as_table }}
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="Search">
</td>
</tr>
</table>

<!-- Begin faceting. -->
<h2>By tags</h2>{{facets.fields}}

<div>
<dl>
{% if facets.fields.tags %}
<dt>Tags</dt>
{# Provide only the top 5 tags #}
{% for tag in facets.fields.tags|slice:":5" %}
<dd><a href="{{ request.get_full_path }}&amp;selected_facets=author_exact:{{ author.0|urlencode }}">{{ tag.0 }}</a> ({{ tag.1 }})</dd>
{% endfor %}
{% else %}
<p>No tag facets.</p>
{% endif %}
</dl>
</div>
<!-- End faceting -->


{% if query %}
<ul>
{% for result in page.object_list %}
{% for result in page_obj.object_list %}
<li>
<a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}
</a>
Expand Down
15 changes: 9 additions & 6 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

from django.conf import settings
from django.conf.urls import url
from django.urls import include, path, re_path
from django.conf.urls.static import static
from django.contrib import admin
Expand All @@ -10,22 +9,26 @@
register_urlconf('blog', 'blog.urls', label='Blog index')

urlpatterns = [
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/', admin.site.urls),
re_path(r'^i18n/', include('django.conf.urls.i18n')),
re_path(r'^admin/', admin.site.urls),
]

try:
import haystack
urlpatterns += [url(r'^search/', include('haystack.urls'), name='haystack_search')]
# urlpatterns += [url(r'^search/', include('haystack.urls'), name='haystack_search')]
from .views import ExampleFacetedSearchView
urlpatterns += [
path('search/', ExampleFacetedSearchView.as_view(), name='haystack_search'),
]
except ImportError:
pass

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

urlpatterns += [
url(r'^$', views.details, {'path': '', 'name': 'pages-root'}),
url(r'^', include('pages.urls')),
re_path(r'^$', views.details, {'path': '', 'name': 'pages-root'}),
re_path(r'^', include('pages.urls')),
]

admin.site.site_header = 'Gerbi Admin'
12 changes: 12 additions & 0 deletions example/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from haystack.forms import FacetedSearchForm
from haystack.generic_views import FacetedSearchView, SearchView



class ExampleFacetedSearchView(FacetedSearchView):

# form_class = FacetedSearchForm
facet_fields = ['tags',]
# template_name = 'search_result.html'
paginate_by = 3
context_object_name = 'object_list'
5 changes: 2 additions & 3 deletions pages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Django page CMS module."""
VERSION = (2, 0, 11)
VERSION = (2, 0, '11b0')
__version__ = '.'.join(map(str, VERSION))
__author__ = "Batiste Bieler"
__contact__ = "[email protected]"
Expand All @@ -10,5 +10,4 @@
__license__ = 'BSD'
__keywords__ = ['django', 'cms']

default_app_config = 'pages.app_config.BasicCmsConfig'

# default_app_config = 'pages.app_config.BasicCmsConfig'
30 changes: 15 additions & 15 deletions pages/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import urllib
from collections import defaultdict
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.utils.translation import gettext_lazy as _
from django.utils.encoding import force_str
from django.conf import settings as global_settings
from django.http import HttpResponseRedirect, Http404
from django.contrib.admin.sites import AlreadyRegistered
Expand Down Expand Up @@ -85,29 +85,29 @@ class Media:

def get_urls(self):
urls = super(PageAdmin, self).get_urls()
from django.conf.urls import url
from django.urls import re_path

pages_urls = [
url(r'^$', self.list_pages, name='page-changelist'),
url(r'^(?P<page_id>[0-9]+)/traduction/(?P<language_id>[-\w]+)/$',
re_path(r'^$', self.list_pages, name='page-changelist'),
re_path(r'^(?P<page_id>[0-9]+)/traduction/(?P<language_id>[-\w]+)/$',
views.traduction, name='page-traduction'),
url(r'^(?P<page_id>[0-9]+)/get-content/(?P<content_id>[0-9]+)/$',
re_path(r'^(?P<page_id>[0-9]+)/get-content/(?P<content_id>[0-9]+)/$',
views.get_content, name='page-get-content'),
url(r'^(?P<page_id>[0-9]+)/modify-content/(?P<content_type>[-\w]+)/(?P<language_id>[-\w]+)/$',
re_path(r'^(?P<page_id>[0-9]+)/modify-content/(?P<content_type>[-\w]+)/(?P<language_id>[-\w]+)/$',
views.modify_content, name='page-modify-content'),
url(r'^(?P<page_id>[0-9]+)/modify-placeholder/$',
re_path(r'^(?P<page_id>[0-9]+)/modify-placeholder/$',
views.modify_placeholder, name='page-modify-placeholder'),
url(r'^(?P<page_id>[0-9]+)/get-last-content/$',
re_path(r'^(?P<page_id>[0-9]+)/get-last-content/$',
views.get_last_content, name='page-get-last-content'),
url(r'^(?P<page_id>[0-9]+)/delete-content/(?P<language_id>[-\w]+)/$',
re_path(r'^(?P<page_id>[0-9]+)/delete-content/(?P<language_id>[-\w]+)/$',
views.delete_content, name='page-delete-content'),
url(r'^(?P<page_id>[0-9]+)/sub-menu/$',
re_path(r'^(?P<page_id>[0-9]+)/sub-menu/$',
views.sub_menu, name='page-sub-menu'),
url(r'^(?P<page_id>[0-9]+)/move-page/$',
re_path(r'^(?P<page_id>[0-9]+)/move-page/$',
views.move_page, name='page-move-page'),
url(r'^(?P<page_id>[0-9]+)/change-status/$',
re_path(r'^(?P<page_id>[0-9]+)/change-status/$',
views.change_status, name='page-change-status'),
url(r'^(?P<media_id>[0-9]+)/media-url/$',
re_path(r'^(?P<media_id>[0-9]+)/media-url/$',
views.get_media_url, name='get-media-url'),
]

Expand Down Expand Up @@ -230,7 +230,7 @@ def get_form(self, request, obj=None, **kwargs):
template_choices.insert(0, (settings.PAGE_DEFAULT_TEMPLATE,
_('Default template')))
form.base_fields['template'].choices = template_choices
form.base_fields['template'].initial = force_text(template)
form.base_fields['template'].initial = force_str(template)

for placeholder in get_placeholders(template):
ctype = placeholder.ctype
Expand Down
6 changes: 3 additions & 3 deletions pages/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"""Page CMS forms"""
from django import forms
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.conf import settings as global_settings

from pages import settings
from pages.models import Page, Content

from pages.urlconf_registry import get_choices
from pages.widgets import LanguageChoiceWidget
import collections
import collections.abc

error_dict = {
'another_page_error': _('Another page with this slug already exists'),
Expand All @@ -23,7 +23,7 @@
def automatic_slug_renaming(slug, is_slug_safe):
"""Helper to add numbers to slugs"""

if not isinstance(is_slug_safe, collections.Callable):
if not isinstance(is_slug_safe, collections.abc.Callable):
raise TypeError('is_slug_safe must be callable')

if is_slug_safe(slug):
Expand Down
3 changes: 2 additions & 1 deletion pages/app_config.py → pages/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class BasicCmsConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'pages'
verbose_name = _("Pages")

Expand Down
2 changes: 1 addition & 1 deletion pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from django.db import models
from django.conf import settings as django_settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.safestring import mark_safe
from django.urls import reverse
from django.conf import settings as global_settings
Expand Down
2 changes: 1 addition & 1 deletion pages/placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.forms import Textarea, ImageField, CharField, FileField
from django.forms import TextInput
from django.conf import settings as global_settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.safestring import mark_safe
from django.utils.text import unescape_string_literal
from django.template.loader import render_to_string
Expand Down
2 changes: 1 addition & 1 deletion pages/plugins/jsonexport/actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.http import HttpResponse
from django.db import transaction
from django.shortcuts import render
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.core.management.base import BaseCommand, CommandError
from pages.plugins.jsonexport.utils import (pages_to_json,
monkeypatch_remove_pages_site_restrictions)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth import get_user_model
from pages.plugins.jsonexport.utils import (json_to_pages,
Expand Down
2 changes: 1 addition & 1 deletion pages/plugins/jsonexport/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db.models import Max
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.sites.models import Site
from django.conf import settings as global_settings
from django.contrib.auth import get_user_model
Expand Down
11 changes: 10 additions & 1 deletion pages/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pages.models import Page
from pages import settings

from haystack.indexes import SearchIndex, CharField, DateTimeField, Indexable
from haystack.indexes import SearchIndex, CharField, DateTimeField, Indexable, MultiValueField

PAGE_TAGGING = getattr(settings, 'PAGE_TAGGING', False)


# This is obsolete if you use haystack 2.0, use the HAYSTACK_SIGNAL_PROCESSOR
# setting instead
Expand Down Expand Up @@ -40,13 +43,19 @@ class PageIndex(SearchIndex, Indexable):
title = CharField(model_attr='title')
url = CharField(model_attr='get_absolute_url')
publication_date = DateTimeField(model_attr='publication_date')
if PAGE_TAGGING:
tags = MultiValueField(model_attr='tags', faceted=True)

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return Page.objects.published()

def get_model(self):
return Page

def prepare_tags(self, object):
"""on render les tags taggit"""
return [tag.name for tag in object.tags.all()]

def should_update(self, instance, **kwargs):
return instance.status == Page.PUBLISHED
Expand Down
4 changes: 2 additions & 2 deletions pages/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
the appropriate settings."""
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
import collections
import collections.abc

url = 'http://packages.python.org/django-page-cms/settings-list.html#%s'

Expand Down Expand Up @@ -52,7 +52,7 @@ def get_page_templates():
"""The callable that is used by the CMS."""
PAGE_TEMPLATES = get_setting('PAGE_TEMPLATES',
default_value=())
if isinstance(PAGE_TEMPLATES, collections.Callable):
if isinstance(PAGE_TEMPLATES, collections.abc.Callable):
return PAGE_TEMPLATES()
else:
return PAGE_TEMPLATES
Expand Down
4 changes: 2 additions & 2 deletions pages/templates/admin/pages/page/includes/fieldset.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<p class="help">{{ field.field.help_text|safe }}</p>
{% endif %}
{% for p in placeholders %}
{% ifequal p.ctype field.field.name %}
{% if p.ctype == field.field.name %}
{% if not add %}
{% show_revisions page p.ctype language %}
{% endif %}
{% endifequal %}
{% endif %}
{% endfor %}
</div>
{% endfor %}
Expand Down
18 changes: 9 additions & 9 deletions pages/templates/admin/pages/page/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@
</td>
{% if can_publish %}
<td class="publish-cell">
{% ifequal page.status page.DRAFT %}
{% if page.status == page.DRAFT %}
<img src="{{ PAGES_STATIC_URL }}images/icons/draft.svg" alt="draft" />
{% else %}{% ifequal page.status page.PUBLISHED %}
{% else %}{% if page.status == page.PUBLISHED %}
<img src="{{ PAGES_STATIC_URL }}images/icons/published.svg" alt="published" />
{% else %}
<img src="{{ PAGES_STATIC_URL }}images/icons/hidden.svg" alt="hidden"/>
{% endifequal %}{% endifequal %}
{% endif %}{% endif %}
&nbsp;
<select class="publish-select" name="select-status-{{ page.id }}">
<option value="0" {% ifequal page.status page.DRAFT %}selected="selected"{% endifequal %}>{% trans "Draft" %}</option>
<option value="1" {% ifequal page.status page.PUBLISHED %}selected="selected"{% endifequal %}>{% trans "Published" %}</option>
<option value="3" {% ifequal page.status page.HIDDEN %}selected="selected"{% endifequal %}>{% trans "Hidden" %}</option>
<option value="0" {% if page.status == page.DRAFT %}selected="selected"{% endif %}>{% trans "Draft" %}</option>
<option value="1" {% if page.status == page.PUBLISHED %}selected="selected"{% endif %}>{% trans "Published" %}</option>
<option value="3" {% if page.status == page.HIDDEN %}selected="selected"{% endif %}>{% trans "Hidden" %}</option>
</select>
</td>
{% else %}
<td>
{% ifequal page.status page.DRAFT %}{% trans "Draft" %}{% endifequal %}
{% ifequal page.status page.PUBLISHED %}{% trans "In navigation" %}{% endifequal %}
{% ifequal page.status page.HIDDEN %}{% trans "Hidden" %}{% endifequal %}
{% if page.status == page.DRAFT %}{% trans "Draft" %}{% endif %}
{% if page.status == page.PUBLISHED %}{% trans "In navigation" %}{% endif %}
{% if page.status == page.HIDDEN %}{% trans "Hidden" %}{% endif %}
</td>
{% endif %}
<td class="template-cell">
Expand Down
Loading