Permalink
Browse files

Autocomplete on tags

  • Loading branch information...
1 parent 996a380 commit e5934dfd46d58019305b969c9aedfc027eab411f @elpaso elpaso committed Oct 6, 2012
@@ -10,8 +10,8 @@
import datetime, os, re
# Tagging
-from taggit.managers import TaggableManager
-
+#from taggit.managers import TaggableManager
+from taggit_autosuggest.managers import TaggableManager
PLUGINS_STORAGE_PATH = getattr(settings, 'PLUGINS_STORAGE_PATH', 'packages')
PLUGINS_FRESH_DAYS = getattr(settings, 'PLUGINS_FRESH_DAYS', 30)
@@ -1,4 +1,37 @@
{% extends 'plugins/plugin_base.html' %}{% load i18n %}
+{% block extrajs %}
+{{ block.super }}
+<script type="text/javascript" src="/static/js/jquery-1.5.1.min.js"></script>
+<link rel="stylesheet" media="all" type="text/css" href="/static/jquery-autosuggest/css/autoSuggest.css">
+<style type="text/css">
+/* for autocomplete */
+.vTextField {
+ width: 20em;
+}
+
+ul.vTextField {
+ padding-bottom:0;
+}
+
+ul.as-list {
+ margin: 0 0 0 0.5em !important;
+ border: solid 1px #ddd !important;
+}
+
+#id_tags__tagautosuggest {
+ height: 16px !important;
+ margin-top: 1em;
+}
+
+</style>
+<script type="text/javascript">
+ // Puts the included jQuery into our own namespace
+ var django = {
+ "jQuery": jQuery.noConflict(true)
+ };
+</script>
+<script src="/static/jquery-autosuggest/js/jquery.autoSuggest.minified.js" type="text/javascript"></script>
+{% endblock %}
{% block content %}
<h2>{{ form_title }}</h2>
{% if form.non_field_errors %}
@@ -18,5 +51,36 @@
<input type="submit" value="{% trans "Save" %}" /> <a class="button" href="javascript:history.back()">{% trans "Back" %}</a>
</div>
</form>
+ <script type="text/javascript">
+ (function ($) {
+ var tags_as_string;
+ $(document).ready(function (){
+ tags_as_string = $('#id_tags').val();
+ $('#id_tags').hide();
+ $('#id_tags').before('<input type="text" id="id_tags__tagautosuggest" value="" name="tags" autocomplete="off" class="as-input vTextField"><br />');
+ $("#id_tags__tagautosuggest").val(tags_as_string);
+ $("#id_tags__tagautosuggest").autoSuggest("/taggit_autosuggest/list/", {
+ asHtmlID: "id_tags__tagautosuggest",
+ startText: "Enter Tag Here",
+ emptyText: "Not found (press TAB to add)",
+ limitText: "No More Selections Are Allowed",
+ preFill: tags_as_string,
+ queryParam: 'q',
+ retrieveLimit: 100,
+ minChars: 1,
+ neverSubmit: true
+ });
+
+ $('.as-selections').addClass('vTextField');
+ $('ul.as-selections li.as-original input').addClass('vTextField');
+
+ $('#id_tags').parents().find('form').submit(function (){
+ tags_as_string = $("#as-values-id_tags__tagautosuggest").val();
+ $("#id_tags__tagautosuggest").remove();
+ $("#id_tags").val(tags_as_string);
+ });
+ });
+ })(django.jQuery);
+ </script>
{% endblock %}
View
@@ -52,11 +52,13 @@ def plugin_notify(plugin):
-def plugin_approve_notify(plugin, msg):
+def plugin_approve_notify(plugin, msg, user):
"""
Sends a message when a plugin is approved or unapproved.
"""
recipients = [u.email for u in plugin.editors if u.email]
+ if settings.QGIS_DEV_MAILING_LIST_ADDRESS:
+ recipients.append(settings.QGIS_DEV_MAILING_LIST_ADDRESS)
if plugin.approved:
approval_state = 'approval'
approved_state = 'approved'
@@ -70,7 +72,7 @@ def plugin_approve_notify(plugin, msg):
logging.debug('Sending email %s notification for %s plugin, recipients: %s' % (approval_state, plugin, recipients))
send_mail(
_('Plugin %s %s notification.') % (plugin, approval_state),
- _('\r\nPlugin %s %s.\r\n%s\r\nLink: http://%s%s\r\n') % (plugin.name, approval_state, msg, domain, plugin.get_absolute_url()),
+ _('\r\nPlugin %s %s by %s.\r\n%s\r\nLink: http://%s%s\r\n') % (plugin.name, approval_state, user, msg, domain, plugin.get_absolute_url()),
mail_from,
recipients,
fail_silently=True)
@@ -635,7 +637,7 @@ def version_approve(request, package_name, version):
version.save()
msg = _("The plugin version \"%s\" is now approved" % version)
messages.success(request, msg, fail_silently=True)
- plugin_approve_notify(version.plugin, msg)
+ plugin_approve_notify(version.plugin, msg, request.user)
try:
redirect_to = request.META['HTTP_REFERER']
except:
@@ -659,7 +661,7 @@ def version_unapprove(request, package_name, version):
version.save()
msg = _("The plugin version \"%s\" is now unapproved" % version)
messages.success(request, msg, fail_silently=True)
- plugin_approve_notify(version.plugin, msg)
+ plugin_approve_notify(version.plugin, msg, request.user)
try:
redirect_to = request.META['HTTP_REFERER']
except:
View
@@ -5,9 +5,6 @@
TEMPLATE_DEBUG = False
-
-
-
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
@@ -118,6 +115,7 @@
'django.contrib.syndication',
'ratings',
'taggit',
+ 'taggit_autosuggest',
'taggit_templatetags',
'haystack',
'django.contrib.flatpages',
@@ -199,7 +197,11 @@
# rpc4django
RPC4DJANGO_LOG_REQUESTS_RESPONSES = False
+#QGIS dev list email address for plugins approval notifications
+QGIS_DEV_MAILING_LIST_ADDRESS=''
+# Media URL for taggit autocomplete
+TAGGIT_AUTOCOMPLETE_JS_BASE_URL=MEDIA_ROOT + '/taggit-autocomplete'
# auth overrids
from settings_auth import *
@@ -0,0 +1,194 @@
+/* AutoSuggest CSS - Version 1.2 */
+.grp-row.grp-cells-1.tags {
+ overflow: visible;
+}
+
+ul.as-selections {
+ list-style-type: none;
+ padding: 4px 0 4px 4px;
+ margin: 0;
+ overflow: auto;
+}
+
+ul.as-selections.loading {
+ background-color: #eee;
+}
+
+ul.as-selections li {
+ float: left;
+ margin: 1px 4px 1px 0;
+}
+
+ul.as-selections li.as-selection-item {
+ color: #2b3840;
+ text-shadow: 0 1px 1px #fff;
+ background-color: #ddeefe;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ddeefe), to(#bfe0f1));
+ border: 1px solid #acc3ec;
+ border-top-color: #c0d9e9;
+ padding: 2px 7px 2px 10px;
+ border-radius: 12px;
+ -webkit-border-radius: 12px;
+ -moz-border-radius: 12px;
+ box-shadow: 0 1px 1px #e4edf2;
+ -webkit-box-shadow: 0 1px 1px #e4edf2;
+ -moz-box-shadow: 0 1px 1px #e4edf2;
+}
+
+ul.as-selections li.as-selection-item:last-child {
+ margin-left: 30px;
+}
+
+ul.as-selections li.as-selection-item a.as-close {
+ float: right;
+ margin: 1px 0 0 7px;
+ padding: 0 2px;
+ cursor: pointer;
+ color: #5491be;
+ text-shadow: 0 1px 1px #fff;
+ -webkit-transition: color .1s ease-in;
+}
+
+ul.as-selections li.as-selection-item.blur {
+ color: #666666;
+ background-color: #f4f4f4;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f4f4f4), to(#d5d5d5));
+ border-color: #bbb;
+ border-top-color: #ccc;
+ box-shadow: 0 1px 1px #e9e9e9;
+ -webkit-box-shadow: 0 1px 1px #e9e9e9;
+ -moz-box-shadow: 0 1px 1px #e9e9e9;
+}
+
+ul.as-selections li.as-selection-item.blur a.as-close {
+ color: #999;
+}
+
+ul.as-selections li:hover.as-selection-item {
+ color: #2b3840;
+ background-color: #bbd4f1;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#bbd4f1), to(#a3c2e5));
+ border-color: #6da0e0;
+ border-top-color: #8bb7ed;
+}
+
+ul.as-selections li:hover.as-selection-item a.as-close {
+ color: #4d70b0;
+}
+
+ul.as-selections li.as-selection-item.selected {
+ border-color: #1f30e4;
+}
+
+ul.as-selections li.as-selection-item a:hover.as-close {
+ color: #1b3c65;
+}
+
+ul.as-selections li.as-selection-item a:active.as-close {
+ color: #4d70b0;
+}
+
+ul.as-selections li.as-original {
+ margin-left: 0;
+}
+
+ul.as-selections li.as-original input {
+ height: 25px !important;
+}
+
+ul.as-list {
+ position: absolute;
+ list-style-type: none;
+ background-color: #fff;
+ background-color: rgba(255,255,255,0.95);
+ z-index: 2;
+ box-shadow: 0 12px #222;
+ -webkit-box-shadow: 0 2px 12px #222;
+ -moz-box-shadow: 0 2px 12px #222;
+ border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+}
+
+li.as-result-item, li.as-message {
+ background-color: transparent;
+ border: 1px solid #fff;
+ border-bottom: 1px solid #ddd;
+ cursor: pointer;
+ border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+}
+
+li:first-child.as-result-item {
+ margin: 0;
+}
+
+li.as-message {
+ margin: 0;
+ cursor: default;
+}
+
+li.as-result-item.active {
+ background-color: #bbd4f1;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#bbd4f1), to(#a3c2e5));
+ border-color: #6DA0E0;
+ color: #000;
+}
+
+li.as-result-item em {
+ font-style: normal;
+ background: #444;
+ padding: 0 2px;
+ color: #fff;
+}
+
+li.as-result-item.active em {
+ background: #253f7a;
+ color: #fff;
+}
+
+/* Webkit Hacks */
+@media screen and (-webkit-min-device-pixel-ratio:0) {
+ ul.as-selections {
+ border-top-width: 2px;
+ }
+ ul.as-selections li.as-selection-item {
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ ul.as-selections li.as-selection-item a.as-close {
+ margin-top: -1px;
+ }
+ ul.as-selections li.as-original input {
+ height: 19px;
+ }
+}
+
+/* Opera Hacks */
+@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
+ ul.as-list {
+ border: 1px solid #888;
+ }
+ ul.as-selections li.as-selection-item a.as-close {
+ margin-left: 4px;
+ margin-top: 0;
+ }
+}
+
+/* IE Hacks */
+ul.as-list {
+ border: 1px solid #888\9;
+}
+ul.as-selections li.as-selection-item a.as-close {
+ margin-left: 4px\9;
+ margin-top: 0\9;
+}
+
+/* Firefox 3.0 Hacks */
+ul.as-list, x:-moz-any-link, x:default {
+ border: 1px solid #888;
+}
+BODY:first-of-type ul.as-list, x:-moz-any-link, x:default { /* Target FF 3.5+ */
+ border: none;
+}
Oops, something went wrong.

0 comments on commit e5934df

Please sign in to comment.