Manage colorbox popup for django
Project description
coop-colorbox, make easy to use jquery.colorbox in a django app
===============================================
Install
=======
pip install apidev_coop-colorbox
Settings
=======
INSTALLED_APPS = (
'...',
'colorbox',
)
Views
=======
from django.utils.decorators import method_decorator
from django.http import HttpResponseRedirect, Http404
from colorbox.decorators import popup_redirect
class MyView(FormView):
"""edit the profile of the current user"""
template_name = "form_popup_template.html"
@method_decorator(popup_redirect)
def dispatch(self, request, *args, **kwargs):
"""Manage close of the colorbox popup"""
self.user = request.user
return super(EditProfileView, self).dispatch(request, *args, **kwargs)
def get_form_class(self):
"""returns the form class to use"""
return MyForm
def form_valid(self, form):
form.save()
return HttpResponseRedirect(reverse(’next_step'))
form_popup_template
=======
{% extends "colorbox/popup_form_base.html" %}
{% load i18n %}
{% block title %}{% trans "Edit" %}{% endblock %}
{% block form_url %}{% url 'my_view' %}{% endblock %}
You can also overrides or extends `{% block form_intro %}` {% block form_fields %}` `{% block popup_buttons %}`
or `{% block extra_head %}`
main template
=======
{% load static i18n %}
<script type="text/javascript" charset="utf-8" src="{% static 'js/jquery.colorbox-min.js' %}"></script>
<script type="text/javascript" charset="utf-8" src="{% static 'js/jquery.form.js' %}"></script>
<script type="text/javascript" src="{% static 'js/colorbox.coop.js' %}"></script>
<link rel="stylesheet" href="{% static 'css/colorbox.css' %}" type="text/css" />
<script>
$(function () {
// activate popups
$("a.colorbox-form").colorboxify();
});
</script>
<a class="colorbox-form" href="{% url 'my_view' %}">{% trans "Edit" %}</a>
In tests
=======
from colorbox.utils import assert_popup_redirects
assert_popup_redirects(response, reverse('my_view'))
License
=======
coop-colorbox uses the BSD license see license.txt
===============================================
Install
=======
pip install apidev_coop-colorbox
Settings
=======
INSTALLED_APPS = (
'...',
'colorbox',
)
Views
=======
from django.utils.decorators import method_decorator
from django.http import HttpResponseRedirect, Http404
from colorbox.decorators import popup_redirect
class MyView(FormView):
"""edit the profile of the current user"""
template_name = "form_popup_template.html"
@method_decorator(popup_redirect)
def dispatch(self, request, *args, **kwargs):
"""Manage close of the colorbox popup"""
self.user = request.user
return super(EditProfileView, self).dispatch(request, *args, **kwargs)
def get_form_class(self):
"""returns the form class to use"""
return MyForm
def form_valid(self, form):
form.save()
return HttpResponseRedirect(reverse(’next_step'))
form_popup_template
=======
{% extends "colorbox/popup_form_base.html" %}
{% load i18n %}
{% block title %}{% trans "Edit" %}{% endblock %}
{% block form_url %}{% url 'my_view' %}{% endblock %}
You can also overrides or extends `{% block form_intro %}` {% block form_fields %}` `{% block popup_buttons %}`
or `{% block extra_head %}`
main template
=======
{% load static i18n %}
<script type="text/javascript" charset="utf-8" src="{% static 'js/jquery.colorbox-min.js' %}"></script>
<script type="text/javascript" charset="utf-8" src="{% static 'js/jquery.form.js' %}"></script>
<script type="text/javascript" src="{% static 'js/colorbox.coop.js' %}"></script>
<link rel="stylesheet" href="{% static 'css/colorbox.css' %}" type="text/css" />
<script>
$(function () {
// activate popups
$("a.colorbox-form").colorboxify();
});
</script>
<a class="colorbox-form" href="{% url 'my_view' %}">{% trans "Edit" %}</a>
In tests
=======
from colorbox.utils import assert_popup_redirects
assert_popup_redirects(response, reverse('my_view'))
License
=======
coop-colorbox uses the BSD license see license.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apidev-coop_colorbox-1.4.1.tar.gz
(52.3 kB
view hashes)
Close
Hashes for apidev-coop_colorbox-1.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b381fe1cba41c2c869a935469d5803247f149daaf4887a1db3b3f5ec5c385470 |
|
MD5 | 445df688f82b813f3410c6efaed6a4a4 |
|
BLAKE2b-256 | 8121d0a4af3ccd2312761474e2b4a7ea49f7a836691f355e9292b4915270d000 |