source: cyclope/apps/contacts/admin.py @ 369:f98caac01351

Revision 369:f98caac01351, 2.4 KB checked in by nicoechaniz <nico@…>, 2 years ago (diff)

updated layout middleware. updated some spanish translation for Contacts.

Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright 2010 Código Sur - Nuestra América Asoc. Civil / Fundación Pacificar.
5# All rights reserved.
6#
7# This file is part of Cyclope.
8#
9# Cyclope is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# Cyclope is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22
23from django.conf import settings
24from django.contrib import admin
25from django.utils.translation import ugettext_lazy as _
26from django.utils.importlib import import_module
27
28import cyclope.settings as cyc_settings
29from cyclope.admin import BaseContentAdmin
30from cyclope.core.collections.admin import CollectibleAdmin
31
32from models import Contact, ContactAddress
33from forms import ContactForm
34
35class ContactAddressInline(admin.TabularInline):
36    model = ContactAddress
37    extra = 1
38    fields = ('type', 'country', 'region', 'city', 'street_address', 'phone_number',
39              'post_office_box')
40
41class ContactAdmin(CollectibleAdmin, BaseContentAdmin):
42    form = ContactForm
43    inlines = CollectibleAdmin.inlines + BaseContentAdmin.inlines + [ContactAddressInline]
44
45    list_filter = CollectibleAdmin.list_filter + ('gender', )
46    list_display = ('given_name', 'surname', 'gender', 'email', 'web', 'mobile_phone_number')
47    search_fields = ('given_name', 'surname', 'email', 'web', 'mobile_phone_number')
48
49    fieldsets = (
50        (None, {
51            'fields': ('given_name', 'surname', 'birth_date', 'photo', 'gender',
52                       'email', 'web', 'mobile_phone_number')
53        }),
54    )
55
56    # Add ContactProfile admin as inline if defined in settings
57    if getattr(settings, 'CYCLOPE_CONTACTS_PROFILE_ADMIN_INLINE_MODULE', False):
58        _parts = settings.CYCLOPE_CONTACTS_PROFILE_ADMIN_INLINE_MODULE.split('.')
59        _inl = _parts[-1]
60        _mod = ".".join(_parts[:-1])
61        _module = import_module(_mod)
62        profile_inline = getattr(_module, _inl)
63        inlines.append(profile_inline)
64
65
66
67admin.site.register(Contact, ContactAdmin)
Note: See TracBrowser for help on using the repository browser.