diff --git a/MANIFEST.in b/MANIFEST.in index 7c3965ce..a63f9cbe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ recursive-include combo/locale *.po *.mo # static -recursive-include combo/apps/usersearch/static *.css *.js *.ico *.gif *.png *.jpg recursive-include combo/apps/lingo/static *.css *.js *.ico *.gif *.png *.jpg recursive-include combo/apps/dataviz/static *.css *.js *.ico *.gif *.png *.jpg recursive-include combo/apps/dashboard/static *.js @@ -18,7 +17,6 @@ recursive-include combo/apps/assets/templates *.html recursive-include combo/apps/calendar/templates *.html recursive-include combo/apps/dashboard/templates *.html recursive-include combo/apps/search/templates *.html -recursive-include combo/apps/usersearch/templates *.html recursive-include combo/apps/dataviz/templates *.html recursive-include combo/apps/family/templates *.html recursive-include combo/apps/fargo/templates *.html diff --git a/combo/apps/usersearch/__init__.py b/combo/apps/usersearch/__init__.py deleted file mode 100644 index 50404108..00000000 --- a/combo/apps/usersearch/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# combo - content management system -# Copyright (C) 2014-2016 Entr'ouvert -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import django.apps -from django.utils.translation import ugettext_lazy as _ - -class AppConfig(django.apps.AppConfig): - name = 'combo.apps.usersearch' - verbose_name = _('Backoffice User Search') - - def get_before_urls(self): - from . import urls - return urls.urlpatterns - -default_app_config = 'combo.apps.usersearch.AppConfig' diff --git a/combo/apps/usersearch/migrations/0001_initial.py b/combo/apps/usersearch/migrations/0001_initial.py deleted file mode 100644 index ecbeb545..00000000 --- a/combo/apps/usersearch/migrations/0001_initial.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('auth', '0001_initial'), - ('data', '0015_feedcell_title'), - ] - - operations = [ - migrations.CreateModel( - name='UserSearchCell', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('placeholder', models.CharField(max_length=20)), - ('order', models.PositiveIntegerField()), - ('slug', models.SlugField(verbose_name='Slug', blank=True)), - ('public', models.BooleanField(default=True, verbose_name='Public')), - ('restricted_to_unlogged', models.BooleanField(default=False, verbose_name='Restrict to unlogged users')), - ('groups', models.ManyToManyField(to='auth.Group', verbose_name='Groups', blank=True)), - ('page', models.ForeignKey(to='data.Page', on_delete=models.CASCADE)), - ], - options={ - 'verbose_name': 'User Search', - }, - bases=(models.Model,), - ), - ] diff --git a/combo/apps/usersearch/migrations/0002_usersearchcell_extra_css_class.py b/combo/apps/usersearch/migrations/0002_usersearchcell_extra_css_class.py deleted file mode 100644 index 63efa70e..00000000 --- a/combo/apps/usersearch/migrations/0002_usersearchcell_extra_css_class.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('usersearch', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='usersearchcell', - name='extra_css_class', - field=models.CharField(max_length=100, verbose_name='Extra classes for CSS styling', blank=True), - ), - ] diff --git a/combo/apps/usersearch/migrations/0003_usersearchcell_last_update_timestamp.py b/combo/apps/usersearch/migrations/0003_usersearchcell_last_update_timestamp.py deleted file mode 100644 index a4e63b79..00000000 --- a/combo/apps/usersearch/migrations/0003_usersearchcell_last_update_timestamp.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models -import datetime -from django.utils.timezone import utc - - -class Migration(migrations.Migration): - - dependencies = [ - ('usersearch', '0002_usersearchcell_extra_css_class'), - ] - - operations = [ - migrations.AddField( - model_name='usersearchcell', - name='last_update_timestamp', - field=models.DateTimeField(default=datetime.datetime.now(utc), auto_now=True), - preserve_default=False, - ), - ] diff --git a/combo/apps/usersearch/migrations/__init__.py b/combo/apps/usersearch/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/combo/apps/usersearch/models.py b/combo/apps/usersearch/models.py deleted file mode 100644 index f1f38c18..00000000 --- a/combo/apps/usersearch/models.py +++ /dev/null @@ -1,44 +0,0 @@ -# combo - content management system -# Copyright (C) 2014-2016 Entr'ouvert -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from django.conf import settings -from django.utils.translation import ugettext_lazy as _ -from django.contrib.auth.models import User - -from combo.data.models import CellBase -from combo.data.library import register_cell_class - - -@register_cell_class -class UserSearchCell(CellBase): - template_name = 'combo/usersearch.html' - - class Media: - js = ('js/usersearch.js',) - - class Meta: - verbose_name = _('User Search') - - @classmethod - def is_enabled(cls): - return settings.USERSEARCH_CELL_ENABLED - - def is_visible(self, user=None): - return super(UserSearchCell, self).is_visible(user=user) - - def modify_global_context(self, context, request): - if 'selected_user_id' in request.GET: - context['selected_user'] = User.objects.get(pk=request.GET['selected_user_id']) diff --git a/combo/apps/usersearch/static/js/usersearch.js b/combo/apps/usersearch/static/js/usersearch.js deleted file mode 100644 index 83807204..00000000 --- a/combo/apps/usersearch/static/js/usersearch.js +++ /dev/null @@ -1,21 +0,0 @@ -$(function() { - $('.usersearch').delegate('input', 'keyup', function() { - var q = $(this).val(); - var search_result_ul = $(this).parent().find('ul.result'); - search_result_ul.empty(); - $.getJSON($(this).data('autocomplete-json'), - {'q': q}, - function (response) { - search_result_ul.empty(); - $(response).each(function(idx, elem) { - var new_elem = '
  • '; - new_elem = new_elem + elem.fields.first_name + ' ' + elem.fields.last_name; - new_elem = new_elem + ' '; - new_elem = new_elem + '
  • ' - $(new_elem).appendTo(search_result_ul); - }); - } - ); - return false; - }); -}); diff --git a/combo/apps/usersearch/templates/combo/usersearch.html b/combo/apps/usersearch/templates/combo/usersearch.html deleted file mode 100644 index baa958f0..00000000 --- a/combo/apps/usersearch/templates/combo/usersearch.html +++ /dev/null @@ -1,11 +0,0 @@ -{% load i18n %} -
    - -
      - {% if selected_user %} -
      - {% trans "Selected user is:" %} {{ selected_user.first_name }} {{ selected_user.last_name }} - -
      - {% endif %} -
      diff --git a/combo/apps/usersearch/urls.py b/combo/apps/usersearch/urls.py deleted file mode 100644 index 00e25775..00000000 --- a/combo/apps/usersearch/urls.py +++ /dev/null @@ -1,24 +0,0 @@ -# combo - content management system -# Copyright (C) 2014-2016 Entr'ouvert -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from django.conf.urls import url - -from .views import ajax_usersearch - -urlpatterns = [ - url(r'^ajax/usersearch/$', - ajax_usersearch, name='combo-ajax-usersearch'), -] diff --git a/combo/apps/usersearch/views.py b/combo/apps/usersearch/views.py deleted file mode 100644 index 81d7286c..00000000 --- a/combo/apps/usersearch/views.py +++ /dev/null @@ -1,50 +0,0 @@ -# combo - content management system -# Copyright (C) 2014-2016 Entr'ouvert -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import json - -from django.http import HttpResponse -from django.contrib.auth.models import User -from django.db.models import Q -from django.core import serializers -from django.core.exceptions import PermissionDenied - -from .models import UserSearchCell - - -def ajax_usersearch(request): - # allow access if the user can see at least one UserSearch cell - for cell in UserSearchCell.objects.all(): - if cell.is_visible(request.user) and cell.page.is_visible(request.user): - break - else: - raise PermissionDenied - query = request.GET.get('q') - if query: - users = User.objects.all() - # pseudo full-text search - for elem in query.split(): - users = users.filter(Q(username__icontains=elem) - |Q(first_name__icontains=elem) - |Q(last_name__icontains=elem) - |Q(email__icontains=elem)) - users = json.loads(serializers.serialize( - 'json', users[:10], fields=('username', 'first_name', 'last_name', 'email'))) - else: - users = [] - response = HttpResponse(content_type='application/json') - json.dump(users, response, indent=2) - return response diff --git a/combo/settings.py b/combo/settings.py index 8d2982e7..eb0f3d29 100644 --- a/combo/settings.py +++ b/combo/settings.py @@ -72,7 +72,6 @@ INSTALLED_APPS = ( 'combo.apps.fargo', 'combo.apps.notifications', 'combo.apps.search', - 'combo.apps.usersearch', 'combo.apps.maps', 'combo.apps.calendar', 'combo.apps.pwa', @@ -345,7 +344,6 @@ PWA_NOTIFICATION_ICON_URL = None BOOKING_CALENDAR_CELL_ENABLED = False LEGACY_CHART_CELL_ENABLED = False NEWSLETTERS_CELL_ENABLED = False -USERSEARCH_CELL_ENABLED = False local_settings_file = os.environ.get('COMBO_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py'))