# combo - content management system # Copyright (C) 2015 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.utils.translation import ugettext_lazy as _ from combo.data.models import CellBase from combo.data.library import register_cell_class from .utils import is_family_enabled, get_family @register_cell_class class FamilyInfosCell(CellBase): template_name = 'family/infos.html' user_dependant = True class Meta: verbose_name = _('Family Information Cell') class Media: js = ('xstatic/jquery-ui.min.js', 'js/gadjo.js',) @classmethod def is_enabled(cls): return is_family_enabled() def get_cell_extra_context(self, context): if context.get('placeholder_search_mode'): return {} user = self.get_concerned_user(context) if not user or user.is_anonymous: return {} response = get_family(user=user, raise_if_not_cached=not(context.get('synchronous'))) if response.status_code == 200: return {'family': response.json()} return {'error': _('An error occured while retrieving family details.')}