Permalink
Browse files

refactoring to work with mezzanine 1.4.3 and django 1.5

--HG--
branch : enhancements
  • Loading branch information...
1 parent 75ad552 commit 8a7fd5ddf0d93ca406c3fee59c06bdc491cdee70 @osiloke committed Mar 27, 2013
View
@@ -1,6 +1,6 @@
OVERVIEW
=========
-:Author: Osi Emoekpere (http://osiloke.blogspot.com, http://twitter.com/osilocks)
+:Author: Osi Emoekpere (http://osiloke.com, http://twitter.com/osilocks)
:info: This app extends mezzanine applications by provides an interface for adding dynamic custom content like a twitter mentions widget or slideshow to mezzanine pages.
@@ -13,7 +13,7 @@ Features
Requirements
============
-mezzanine 1.x.x (I'm not sure if 1.0 is backwards compatible)
+mezzanine 1.x.x
django-classy-tags
METHODOLOGY
@@ -117,10 +117,13 @@ Change directory to the example app and run::
python manage.py createdb --noinput
-The gallery page has a couple of widgets, so take a look at that first.
+This will create a demo mezzanine applciation, To test out mezzanine widgets go to any mezzanine page (about, gallery etc) and click the `add widget` button to add a new widget.
+
+Run tests from the example folder with::
+
+python manage.py test widget --settings=test_settings
TODO
====
* Better presentation of widget list in frontend.
-* Sorting and swapping widgets
-* More render options
+* More render options, like provide template for widget list wrap
@@ -1 +1 @@
-Mezzanine==0.12
+mezzanine-widgets
View
@@ -3,18 +3,20 @@
# MEZZANINE SETTINGS #
######################
-# The following settings are already defined in mezzanine.conf.defaults
-# with default values, but are common enough to be put here, commented
-# out, for convenient overriding.
+# The following settings are already defined with default values in
+# the ``defaults.py`` module within each of Mezzanine's apps, but are
+# common enough to be put here, commented out, for convenient
+# overriding. Please consult the settings documentation for a full list
+# of settings Mezzanine implements:
+# http://mezzanine.jupo.org/docs/configuration.html#default-settings
# Controls the ordering and grouping of the admin menu.
#
-# from django.utils.translation import ugettext as _
# ADMIN_MENU_ORDER = (
-# (_("Content"), ("pages.Page", "blog.BlogPost",
-# "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
-# (_("Site"), ("sites.Site", "redirects.Redirect", "conf.Setting")),
-# (_("Users"), ("auth.User", "auth.Group",)),
+# ("Content", ("pages.Page", "blog.BlogPost",
+# "generic.ThreadedComment", ("Media Library", "fb_browse"),)),
+# ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
+# ("Users", ("auth.User", "auth.Group",)),
# )
# A three item sequence, each containing a sequence of template tags
@@ -26,6 +28,19 @@
# ("mezzanine_tags.recent_actions",),
# )
+# A sequence of templates used by the ``page_menu`` template tag. Each
+# item in the sequence is a three item sequence, containing a unique ID
+# for the template, a label for the template, and the template path.
+# These templates are then available for selection when editing which
+# menus a page should appear in. Note that if a menu template is used
+# that doesn't appear in this setting, all pages will appear in it.
+
+# PAGE_MENU_TEMPLATES = (
+# (1, "Top navigation bar", "pages/menus/dropdown.html"),
+# (2, "Left-hand tree", "pages/menus/tree.html"),
+# (3, "Footer", "pages/menus/footer.html"),
+# )
+
# A sequence of fields that will be injected into Mezzanine's (or any
# library's) models. Each item in the sequence is a four item sequence.
# The first two items are the dotted path to the model and its field
@@ -35,23 +50,22 @@
# field instance. When specifying the field class, the path
# ``django.models.db.`` can be omitted for regular Django model fields.
#
-# from django.utils.translation import ugettext as _
# EXTRA_MODEL_FIELDS = (
# (
# # Dotted path to field.
# "mezzanine.blog.models.BlogPost.image",
# # Dotted path to field class.
# "somelib.fields.ImageField",
# # Positional args for field class.
-# (_("Image"),),
+# ("Image",),
# # Keyword args for field class.
-# {"blank": True, "upload_to: "blog"},
+# {"blank": True, "upload_to": "blog"},
# ),
# # Example of adding a field to *all* of Mezzanine's content types:
# (
# "mezzanine.pages.models.Page.another_field",
# "IntegerField", # 'django.db.models.' is implied if path is omitted.
-# (_("Another name"),),
+# ("Another name",),
# {"blank": True, "default": 1},
# ),
# )
@@ -60,32 +74,8 @@
#
# BLOG_USE_FEATURED_IMAGE = True
-# Turns on accounts for website visitors. Will add the
-# LOGIN_URL/LOGOUT_URL values to urlpatterns, and show login/logout
-# links in templates/includes/user_panel.html. Defaults to False.
-#
-# ACCOUNTS_ENABLED = True
-
-# If ``True``, users will be automatically redirected to HTTPS
-# for the URLs specified by the ``SSL_FORCE_URL_PREFIXES`` setting.
-#
-# SSL_ENABLED = True
-
-# Host name that the site should always be accessed via that matches
-# the SSL certificate.
-#
-# SSL_FORCE_HOST = "www.example.com"
-
-# Sequence of URL prefixes that will be forced to run over
-# SSL when ``SSL_ENABLED`` is ``True``. i.e.
-# ('/admin', '/example') would force all URLs beginning with
-# /admin or /example to run over SSL. Defaults to:
-#
-# SSL_FORCE_URL_PREFIXES = ("/admin", "/account")
-
# If True, the south application will be automatically added to the
-# INSTALLED_APPS setting. This setting is not defined in
-# mezzanine.conf.defaults as is the case with the above settings.
+# INSTALLED_APPS setting.
USE_SOUTH = True
@@ -108,7 +98,10 @@
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
-TIME_ZONE = ""
+TIME_ZONE = None
+
+# If you set this to True, Django will use timezone-aware datetimes.
+USE_TZ = True
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
@@ -142,9 +135,15 @@
"django.template.loaders.app_directories.Loader",
)
-# URLs used for login/logout when ACCOUNTS_ENABLED is set to True.
-LOGIN_URL = "/account/"
-LOGOUT_URL = "/account/logout/"
+AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+ "django.contrib.staticfiles.finders.FileSystemFinder",
+ "django.contrib.staticfiles.finders.AppDirectoriesFinder",
+# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
#############
@@ -153,8 +152,8 @@
DATABASES = {
"default": {
- # "postgresql_psycopg2", "postgresql", "mysql", "sqlite3" or "oracle".
- "ENGINE": "",
+ # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
+ "ENGINE": "django.db.backends.",
# DB name or path to database file if using sqlite3.
"NAME": "",
# Not used with sqlite3.
@@ -163,7 +162,7 @@
"PASSWORD": "",
# Set to empty string for localhost. Not used with sqlite3.
"HOST": "",
- # Set to empty string for default. Not used with sqlite3.
+ # Set to empty string for default. Not used with sqlite3.
"PORT": "",
}
}
@@ -244,6 +243,7 @@
"mezzanine.twitter",
"widget",
"widgets",
+ #"mezzanine.accounts",
#"mezzanine.mobile",
)
@@ -258,34 +258,37 @@
"django.core.context_processors.static",
"django.core.context_processors.media",
"django.core.context_processors.request",
+ "django.core.context_processors.tz",
"mezzanine.conf.context_processors.settings",
)
# List of middleware classes to use. Order is important; in the request phase,
-# this middleware classes will be applied in the order given, and in the
+# these middleware classes will be applied in the order given, and in the
# response phase the middleware will be applied in reverse order.
MIDDLEWARE_CLASSES = (
+ "mezzanine.core.middleware.UpdateCacheMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.redirects.middleware.RedirectFallbackMiddleware",
- "mezzanine.core.middleware.DeviceAwareUpdateCacheMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
+ "mezzanine.core.request.CurrentRequestMiddleware",
"mezzanine.core.middleware.TemplateForDeviceMiddleware",
- "mezzanine.core.middleware.DeviceAwareFetchFromCacheMiddleware",
+ "mezzanine.core.middleware.TemplateForHostMiddleware",
"mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
- "mezzanine.pages.middleware.PageMiddleware",
+ "mezzanine.core.middleware.SitePermissionMiddleware",
# Uncomment the following if using any of the SSL settings:
# "mezzanine.core.middleware.SSLRedirectMiddleware",
+ "mezzanine.pages.middleware.PageMiddleware",
+ "mezzanine.core.middleware.FetchFromCacheMiddleware",
)
# Store these package names here as they may change in the future since
# at the moment we are using custom forks of them.
PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
-
#########################
# OPTIONAL APPLICATIONS #
#########################
@@ -294,13 +297,37 @@
OPTIONAL_APPS = (
"debug_toolbar",
"django_extensions",
+ "compressor",
PACKAGE_NAME_FILEBROWSER,
PACKAGE_NAME_GRAPPELLI,
)
DEBUG_TOOLBAR_CONFIG = {"INTERCEPT_REDIRECTS": False}
-
+###################
+# DEPLOY SETTINGS #
+###################
+
+# These settings are used by the default fabfile.py provided.
+# Check fabfile.py for defaults.
+
+# FABRIC = {
+# "SSH_USER": "", # SSH username
+# "SSH_PASS": "", # SSH password (consider key-based authentication)
+# "SSH_KEY_PATH": "", # Local path to SSH key file, for key-based auth
+# "HOSTS": [], # List of hosts to deploy to
+# "VIRTUALENV_HOME": "", # Absolute remote path for virtualenvs
+# "PROJECT_NAME": "", # Unique identifier for project
+# "REQUIREMENTS_PATH": "", # Path to pip requirements, relative to project
+# "GUNICORN_PORT": 8000, # Port gunicorn will listen on
+# "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8"
+# "LIVE_HOSTNAME": "www.example.com", # Host for public site.
+# "REPO_URL": "", # Git or Mercurial remote repo URL for the project
+# "DB_PASS": "", # Live database password
+# "ADMIN_PASS": "", # Live admin user password
+# }
+
+ALLOWED_HOSTS = '*'
##################
# LOCAL SETTINGS #
##################
@@ -320,6 +347,13 @@
# set_dynamic_settings() will rewrite globals based on what has been
# defined so far, in order to provide some better defaults where
-# applicable.
-from mezzanine.utils.conf import set_dynamic_settings
-set_dynamic_settings(globals())
+# applicable. We also allow this settings module to be imported
+# without Mezzanine installed, as the case may be when using the
+# fabfile, where setting the dynamic settings below isn't strictly
+# required.
+try:
+ from mezzanine.utils.conf import set_dynamic_settings
+except ImportError:
+ pass
+else:
+ set_dynamic_settings(globals())
@@ -10,8 +10,8 @@
<title>{% block meta_title %}{% endblock %}{% if settings.SITE_TITLE %} | {{ settings.SITE_TITLE }}{% endif %}</title>
{% if "mezzanine.blog"|is_installed %}
-<link rel="alternate" type="application/rss+xml" title="RSS" href="{% url blog_post_feed "rss" %}">
-<link rel="alternate" type="application/atom+xml" title="Atom" href="{% url blog_post_feed "atom" %}">
+<link rel="alternate" type="application/rss+xml" title="RSS" href="{% url "blog_post_feed" "rss" %}">
+<link rel="alternate" type="application/atom+xml" title="Atom" href="{% url "blog_post_feed" "atom" %}">
{% endif %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/bootstrap.css">
@@ -38,7 +38,7 @@
<div class="container">
{% if settings.SITE_TITLE %}<a class="brand" href="/">{{ settings.SITE_TITLE }}</a>{% endif %}
{% if settings.SITE_TAGLINE %}<p class="tagline">{{ settings.SITE_TAGLINE }}</p>{% endif %}
- <form action="{% url search %}" class="navbar-search pull-right">
+ <form action="{% url "search" %}" class="navbar-search pull-right">
<input class="search-query" placeholder="{% trans "Search" %}" type="text" name="q" value="{{ request.REQUEST.q }}">
</form>
{% page_menu "pages/menus/primary.html" %}
@@ -76,7 +76,7 @@
{% block main %}{% endblock %}
</div>
-<div class="span3 right">
+<div class="span3 right">
{% include "includes/user_panel.html" %}
<div class="panel">
{% block right_panel %}
@@ -86,7 +86,7 @@
</div>
</div>
-</div>
+</div>
<footer>
<div class="container">
@@ -102,7 +102,7 @@
Theme by <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>
{% if "mezzanine.mobile"|is_installed %}
<span class="separator">|</span>
- <a href="{% url set_device "mobile" %}?next={{ request.path }}">{% trans "View Mobile Site" %}</a>
+ <a href="{% url "set_device" "mobile" %}?next={{ request.path }}">{% trans "View Mobile Site" %}</a>
{% endif %}
</p>
</div>
@@ -20,4 +20,4 @@
{% endblock %}
{% block main %}
-{% endblock %}
+{% endblock %}
View
@@ -0,0 +1,2 @@
+from settings import *
+DATABASE_ENGINE = 'django.db.backends.sqlite3'
@@ -10,12 +10,12 @@
<h6>
{% trans "Posted by" %}:
{% with blog_post.user as author %}
- <a href="{% url blog_post_list_author author %}">{{ author.get_full_name|default:author.username }}</a>
+ <a href="{% url "blog_post_list_author" author %}">{{ author.get_full_name|default:author.username }}</a>
{% endwith %}
{% if blog_post.category_list %}
{% trans "in" %}
{% for category in blog_post.category_list %}
- <a href="{% url blog_post_list_category category.slug %}">{{ category }}</a>
+ <a href="{% url "blog_post_list_category" category.slug %}">{{ category }}</a>
{% endfor %}
{% endif %}
{{ blog_post.publish_date|timesince }} {% trans "ago" %}
@@ -27,7 +27,7 @@
{% endif %}
{% endif %}
{% if perms.widget.can_delete %}
- <a id="dw-{{ w.widget.id }}-delete" class="widget-delete-link" href="{% url delete_widget w.widget.id %}?next={{request.path}}"><i class="icon-remove"></i></a>
+ <a id="dw-{{ w.widget.id }}-delete" class="widget-delete-link" href="{% url "delete_widget" w.widget.id %}?next={{request.path}}"><i class="icon-remove"></i></a>
{% endif %}
{% if perms.widget.can_change %}
<span class="ordering" style="float:right;">
@@ -5,7 +5,7 @@
<form style="display:none;"
class="popup-form frontend-admin-form form-vertical"
method="post"
- action="{% url widget_list %}" id="widget-form"
+ action="{% url "widget_list" %}" id="widget-form"
{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
{% csrf_token %}
<fieldset id="widget-list" style="border:none;">
Oops, something went wrong.

0 comments on commit 8a7fd5d

Please sign in to comment.