-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better namespacing of fieldnames Better encapsulation of functionality Use sessions to pass form data back to page/plugin when form is invalid, still fallback to GET params when necessary. Call `form_valid` on plugin when form is valid Pass source URL via form field instead of HTTP_REFERER Don't clobber existing GET params Support both forms.Form and forms.ModelForm Cleaner code, use cached_property for efficiency Updated README Bump to 0.1.0
- Loading branch information
1 parent
a1e7cb3
commit 6386431
Showing
8 changed files
with
209 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = '0.0.1' | ||
from __future__ import unicode_literals | ||
|
||
__version__ = '0.1.0' | ||
|
||
|
||
def get_session_key(plugin_id): | ||
return 'cmsplugin_form_{0}'.format(plugin_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import unicode_literals | ||
|
37 changes: 37 additions & 0 deletions
37
cmsplugin_form_handler/templatetags/cmsplugin_form_tags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import unicode_literals | ||
|
||
from django import template | ||
from django.core.urlresolvers import reverse | ||
|
||
from classytags.arguments import Argument | ||
from classytags.core import Options | ||
from classytags.helpers import AsTag | ||
|
||
register = template.Library() | ||
|
||
|
||
class FormAction(AsTag): | ||
name = 'cmsplugin_form_action' | ||
options = Options( | ||
Argument('plugin_id', required=False, resolve=False), | ||
'as', | ||
Argument('varname', required=False, resolve=False), | ||
) | ||
|
||
def get_value(self, context, **kwargs): | ||
""" | ||
If no «plugin_id» is provided, then set plugin_id to `instance.pk` | ||
where `instance` comes from the context and is the plugin instance | ||
which is conventionally added to the context in CMSPluginBase.render(). | ||
""" | ||
plugin_id = kwargs.get('plugin_id') | ||
if not plugin_id and 'instance' in context: | ||
plugin_id = context.get('instance').pk | ||
return reverse( | ||
'cmsplugin_form_handler:process_form', | ||
args=(plugin_id, ) | ||
) | ||
|
||
register.tag(FormAction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters