mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
converted template to use real form
This commit is contained in:
@@ -15,15 +15,6 @@
|
|||||||
{% block extrahead %}
|
{% block extrahead %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{{ media.js }}
|
{{ media.js }}
|
||||||
{% if action_form %}{% if actions_on_top or actions_on_bottom %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
(function($) {
|
|
||||||
$(document).ready(function($) {
|
|
||||||
$("tr input.action-select").actions();
|
|
||||||
});
|
|
||||||
})(django.jQuery);
|
|
||||||
</script>
|
|
||||||
{% endif %}{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}change-list{% endblock %}
|
{% block bodyclass %}change-list{% endblock %}
|
||||||
@@ -89,7 +80,13 @@
|
|||||||
<td>{{ item }}</td>
|
<td>{{ item }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if result.is_enabled and result.approved_at %}
|
{% if result.is_enabled and result.approved_at %}
|
||||||
<td><button data-url="{% url "admin:djrill_disable_sender" %}" data-email="{{ result.address }}">disable</button></td>
|
<td>
|
||||||
|
<form method="post" action="{% url "admin:djrill_disable_sender" %}">
|
||||||
|
<input type="hidden" name="email" value="{{ result.address }}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button>disable</buton>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><button>enable</button></td>
|
<td><button>enable</button></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.http import HttpResponse, HttpResponseForbidden
|
from django.http import HttpResponse, HttpResponseForbidden
|
||||||
@@ -10,6 +11,15 @@ except ImportError:
|
|||||||
raise ImportError("Install the damn requirements!")
|
raise ImportError("Install the damn requirements!")
|
||||||
|
|
||||||
|
|
||||||
|
class DjrillAdminMedia(object):
|
||||||
|
def _media(self):
|
||||||
|
js = ["js/core.js", "js/jquery.min.js", "js/jquery.init.js"]
|
||||||
|
|
||||||
|
return forms.Media(js=["%s%s" % (settings.ADMIN_MEDIA_PREFIX, url)
|
||||||
|
for url in js])
|
||||||
|
media = property(_media)
|
||||||
|
|
||||||
|
|
||||||
class DjrillApiMixin(object):
|
class DjrillApiMixin(object):
|
||||||
"""
|
"""
|
||||||
Simple Mixin to grab the api info from the settings file.
|
Simple Mixin to grab the api info from the settings file.
|
||||||
@@ -52,15 +62,18 @@ class DjrillIndexView(DjrillApiMixin, TemplateView):
|
|||||||
return self.render_to_response({"status": json.loads(req.content)})
|
return self.render_to_response({"status": json.loads(req.content)})
|
||||||
|
|
||||||
|
|
||||||
class DjrillSendersListView(DjrillApiMixin, DjrillApiJsonObjectsMixin,
|
class DjrillSendersListView(DjrillAdminMedia, DjrillApiMixin,
|
||||||
TemplateView):
|
DjrillApiJsonObjectsMixin, TemplateView):
|
||||||
|
|
||||||
api_uri = "users/senders.json"
|
api_uri = "users/senders.json"
|
||||||
template_name = "djrill/senders_list.html"
|
template_name = "djrill/senders_list.html"
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
objects = self.get_json_objects()
|
objects = self.get_json_objects()
|
||||||
return self.render_to_response({"objects": json.loads(objects)})
|
return self.render_to_response({
|
||||||
|
"objects": json.loads(objects),
|
||||||
|
"media": self.media
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class DjrillDisableSenderView(DjrillApiMixin, View):
|
class DjrillDisableSenderView(DjrillApiMixin, View):
|
||||||
|
|||||||
3
urls.py
3
urls.py
@@ -1,5 +1,6 @@
|
|||||||
from django.conf.urls.defaults import patterns, include, url
|
from django.conf.urls.defaults import patterns, include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
|
|
||||||
from djrill import DjrillAdminSite
|
from djrill import DjrillAdminSite
|
||||||
|
|
||||||
@@ -14,3 +15,5 @@ urlpatterns = patterns('',
|
|||||||
# Uncomment the next line to enable the admin:
|
# Uncomment the next line to enable the admin:
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|||||||
Reference in New Issue
Block a user