summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/forms_common.py20
-rw-r--r--ishtar_common/ishtar_menu.py16
-rw-r--r--ishtar_common/menus.py2
-rw-r--r--ishtar_common/models.py8
-rw-r--r--ishtar_common/templates/ishtar/sheet_organization.html41
-rw-r--r--ishtar_common/templates/ishtar/sheet_organization_pdf.html18
-rw-r--r--ishtar_common/templates/ishtar/sheet_organization_window.html3
-rw-r--r--ishtar_common/urls.py9
-rw-r--r--ishtar_common/views.py54
-rw-r--r--ishtar_common/wizards.py6
10 files changed, 156 insertions, 21 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index b6cab8b6a..ec3ccfb8b 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -67,6 +67,8 @@ def get_person_field(label=_(u"Person"), required=True, person_types=[]):
validators=[models.valid_id(models.Person)])
class OrganizationForm(forms.Form):
+ form_label = _(u"Organization")
+ associated_models = {'organization_type':models.OrganizationType}
name = forms.CharField(label=_(u"Name"), max_length=40,
validators=[name_validator])
organization_type = forms.ChoiceField(label=_(u"Organization type"),
@@ -100,6 +102,24 @@ class OrganizationForm(forms.Form):
new_item.save()
return new_item
+class OrganizationSelect(TableSelect):
+ name = forms.CharField(label=_(u"Name"), max_length=30)
+ organization_type = forms.ChoiceField(label=_(u"Type"), choices=[])
+
+ def __init__(self, *args, **kwargs):
+ super(OrganizationSelect, self).__init__(*args, **kwargs)
+ self.fields['organization_type'].choices = \
+ models.OrganizationType.get_types()
+
+class OrganizationFormSelection(forms.Form):
+ form_label = _(u"Organization search")
+ associated_models = {'pk':models.Organization}
+ currents = {'pk':models.Organization}
+ pk = forms.IntegerField(label="",
+ widget=widgets.JQueryJqGrid(reverse_lazy('get-organization'),
+ OrganizationSelect, models.Organization),
+ validators=[models.valid_id(models.Organization)])
+
class PersonSelect(TableSelect):
name = forms.CharField(label=_(u"Name"), max_length=30)
surname = forms.CharField(label=_(u"Surname"), max_length=20)
diff --git a/ishtar_common/ishtar_menu.py b/ishtar_common/ishtar_menu.py
index 1c198ad91..76961aea9 100644
--- a/ishtar_common/ishtar_menu.py
+++ b/ishtar_common/ishtar_menu.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -26,7 +26,8 @@ import models
MENU_SECTIONS = [
(10, SectionItem('administration', _(u"Administration"),
- childs=[SectionItem('person', _(u"Person"),
+ childs=[
+ SectionItem('person', _(u"Person"),
childs=[
MenuItem('person_creation', _(u"Creation"),
model=models.Person,
@@ -35,6 +36,17 @@ MENU_SECTIONS = [
model=models.Person,
access_controls=['change_person', 'change_own_person']),
]),
+ SectionItem('organization', _(u"Organization"),
+ childs=[
+ MenuItem('organization_creation', _(u"Creation"),
+ model=models.Organization,
+ access_controls=['add_organization',
+ 'add_own_organization']),
+ MenuItem('organization_modification', _(u"Modification"),
+ model=models.Organization,
+ access_controls=['change_organization',
+ 'change_own_organization']),
+ ]),
MenuItem('account_management', _(u"Account management"),
model=models.IshtarUser,
access_controls=['add_ishtaruser',]),
diff --git a/ishtar_common/menus.py b/ishtar_common/menus.py
index 77dcabcd3..465692ec6 100644
--- a/ishtar_common/menus.py
+++ b/ishtar_common/menus.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 77a7d6562..473d634fa 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -701,6 +701,7 @@ class OrganizationType(GeneralType):
ordering = ('label',)
class Organization(Address, OwnPerms, ValueGetter):
+ TABLE_COLS = ('name', 'organization_type',)
name = models.CharField(_(u"Name"), max_length=100)
organization_type = models.ForeignKey(OrganizationType,
verbose_name=_(u"Type"))
@@ -719,6 +720,13 @@ class Organization(Address, OwnPerms, ValueGetter):
def __unicode__(self):
return self.name
+ @property
+ def associated_filename(self):
+ values = [unicode(getattr(self, attr))
+ for attr in ('organization_type', 'name')
+ if getattr(self, attr)]
+ return slugify(u"-".join(values))
+
class PersonType(GeneralType):
#rights = models.ManyToManyField(WizardStep, verbose_name=_(u"Rights"))
groups = models.ManyToManyField(Group, verbose_name=_(u"Groups"),
diff --git a/ishtar_common/templates/ishtar/sheet_organization.html b/ishtar_common/templates/ishtar/sheet_organization.html
new file mode 100644
index 000000000..64f8fe5c7
--- /dev/null
+++ b/ishtar_common/templates/ishtar/sheet_organization.html
@@ -0,0 +1,41 @@
+{% extends "ishtar/sheet.html" %}
+{% load i18n %}
+
+{% block head_sheet %}
+{{block.super}}
+<h1>{% trans "Organization"%}</h1>
+{% endblock %}
+
+{% block content %}
+<div class='tool'>{%trans "Export as:"%} <a href='{% url show-organization item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-organization item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
+
+<p><label>{% trans "Name" %}</label> <span class='value'>{{item.name}}</span></p>
+{% if item.address %}<p><label>{% trans "Address" %}</label> <span class='value'>{{item.address}}</span></p> {% endif %}
+{% if item.address_complement %}<p><label>{% trans "Address complement" %}</label> <span class='value'>{{item.address_complement}}</span></p> {% endif %}
+{% if item.postal_code %}<p><label>{% trans "Postal code" %}</label> <span class='value'>{{item.postal_code}}</span></p> {% endif %}
+{% if item.town %}<p><label>{% trans "Town" %}</label> <span class='value'>{{item.town}}</span></p> {% endif %}
+{% if item.phone %}<p><label>{% trans "Phone" %}</label> <span class='value'>{{item.phone}}</span></p> {% endif %}
+{% if item.mobile_phone %}<p><label>{% trans "Mobile phone" %}</label> <span class='value'>{{item.mobile_phone}}</span></p> {% endif %}
+
+
+<table>
+ <caption>{%trans "Person in the organization"%}</caption>
+ <tr>
+ <th>{% trans "Name" %}</th>
+ <th>{% trans "Surname" %}</th>
+ <th>{% trans "Type" %}</th>
+ <th class='link'>&nbsp;</th>
+ </tr>
+ {% for person in item.members.all %}
+ <tr>
+ <td class='string'>{{person.name|default:""}}</td>
+ <td class='string'>{{person.surname|default:""}}</td>
+ <td>{% for type in person.person_types.all %}{% if forloop.counter0 %}, {% endif %}{{type.label}}{% endfor %}</td>
+ <td class='link'><a href="#" onclick='load_window("{%url show-person person.pk ''%}")'>{% trans "Details" %}</a></td>
+ </tr>
+ {% empty %}
+ <tr><td colspan="8" class='no_items'>{% trans "No person in this organization" %}</td></tr>
+ {% endfor %}
+</table>
+
+{% endblock %}
diff --git a/ishtar_common/templates/ishtar/sheet_organization_pdf.html b/ishtar_common/templates/ishtar/sheet_organization_pdf.html
new file mode 100644
index 000000000..79e89ef0b
--- /dev/null
+++ b/ishtar_common/templates/ishtar/sheet_organization_pdf.html
@@ -0,0 +1,18 @@
+{% extends "ishtar/sheet_organization.html" %}
+{% block header %}
+<link rel="stylesheet" href="{{STATIC_URL}}/media/style_basic.css" />
+{% endblock %}
+{% block main_head %}
+{{ block.super }}
+<div id="pdfheader">
+Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
+</div>
+{% endblock %}
+{%block head_sheet%}{%endblock%}
+{%block main_foot%}
+<div id="pdffooter">
+&ndash; <pdf:pagenumber/> &ndash;
+</div>
+</body>
+</html>
+{%endblock%}
diff --git a/ishtar_common/templates/ishtar/sheet_organization_window.html b/ishtar_common/templates/ishtar/sheet_organization_window.html
new file mode 100644
index 000000000..a0e5d9b77
--- /dev/null
+++ b/ishtar_common/templates/ishtar/sheet_organization_window.html
@@ -0,0 +1,3 @@
+{% extends "ishtar/sheet_organization.html" %}
+{% block main_head %}{%endblock%}
+{% block main_foot %}{%endblock%}
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index 35354409e..565db57d5 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -35,6 +35,11 @@ urlpatterns = patterns('',
views.person_creation_wizard, name='person_creation'),
url(r'person_modification/(?P<step>.+)?$',
views.person_modification_wizard, name='person_modification'),
+ url(r'organization_creation/(?P<step>.+)?$',
+ views.organization_creation_wizard, name='organization_creation'),
+ url(r'organization_modification/(?P<step>.+)?$',
+ views.organization_modification_wizard,
+ name='organization_modification'),
url(r'account_management/(?P<step>.+)?$',
views.account_management_wizard, name='account_management'),
)
@@ -70,6 +75,10 @@ urlpatterns += patterns('ishtar_common.views',
name='autocomplete-author'),
url(r'new-organization/(?P<parent_name>.+)?/$',
'new_organization', name='new-organization'),
+ url(r'get-organization/(?P<type>.+)?$', 'get_organization',
+ name='get-organization'),
+ url(r'show-organization/(?P<pk>.+)?/(?P<type>.+)?$',
+ 'show_organization', name='show-organization'),
url(r'autocomplete-organization/([0-9_]+)?$',
'autocomplete_organization', name='autocomplete-organization'),
url(r'(?P<action_slug>' + actions + r')/$', 'action',
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 5e49ddc13..c03870935 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -51,10 +51,8 @@ if settings.XHTML2ODT_PATH:
from menus import menu
from ishtar_common.forms import FinalForm
-from ishtar_common.forms_common import PersonForm, PersonTypeForm, \
- PersonFormSelection, AccountForm, FinalAccountForm, OrganizationForm, \
- AuthorForm, SimplePersonForm
-from ishtar_common.wizards import PersonWizard, PersonModifWizard, AccountWizard
+from ishtar_common import forms_common as forms
+from ishtar_common import wizards
import models
CSV_OPTIONS = {'delimiter':';', 'quotechar':'"', 'quoting':csv.QUOTE_ALL}
@@ -74,25 +72,38 @@ def index(request):
return render_to_response('index.html', dct,
context_instance=RequestContext(request))
-person_creation_wizard = PersonWizard.as_view([
- ('identity-person_creation', SimplePersonForm),
- ('person_type-person_creation', PersonTypeForm),
+person_creation_wizard = wizards.PersonWizard.as_view([
+ ('identity-person_creation', forms.SimplePersonForm),
+ ('person_type-person_creation', forms.PersonTypeForm),
('final-person_creation', FinalForm)],
label=_(u"New person"),
url_name='person_creation')
-person_modification_wizard = PersonModifWizard.as_view([
- ('selec-person_modification', PersonFormSelection),
- ('identity-person_modification', SimplePersonForm),
- ('person_type-person_creation', PersonTypeForm),
+person_modification_wizard = wizards.PersonModifWizard.as_view([
+ ('selec-person_modification', forms.PersonFormSelection),
+ ('identity-person_modification', forms.SimplePersonForm),
+ ('person_type-person_creation', forms.PersonTypeForm),
('final-person_modification', FinalForm)],
label=_(u"Person modification"),
url_name='person_modification')
-account_management_wizard = AccountWizard.as_view([
- ('selec-account_management', PersonFormSelection),
- ('account-account_management', AccountForm),
- ('final-account_management', FinalAccountForm)],
+organization_creation_wizard = wizards.OrganizationWizard.as_view([
+ ('identity-organization_creation', forms.OrganizationForm),
+ ('final-organization_creation', FinalForm)],
+ label=_(u"New organization"),
+ url_name='organization_creation')
+
+organization_modification_wizard = wizards.OrganizationModifWizard.as_view([
+ ('selec-organization_modification', forms.OrganizationFormSelection),
+ ('identity-organization_modification', forms.OrganizationForm),
+ ('final-organization_modification', FinalForm)],
+ label=_(u"Organization modification"),
+ url_name='organization_modification')
+
+account_management_wizard = wizards.AccountWizard.as_view([
+ ('selec-account_management', forms.PersonFormSelection),
+ ('account-account_management', forms.AccountForm),
+ ('final-account_management', forms.FinalAccountForm)],
label=_(u"Account management"),
url_name='account_management',)
@@ -584,9 +595,16 @@ def new_item(model, frm):
context_instance=RequestContext(request))
return func
-new_person = new_item(models.Person, PersonForm)
-new_organization = new_item(models.Organization, OrganizationForm)
-new_author = new_item(models.Author, AuthorForm)
+new_person = new_item(models.Person, forms.PersonForm)
+new_organization = new_item(models.Organization, forms.OrganizationForm)
+show_organization = show_item(models.Organization, 'organization')
+get_organization = get_item(models.Organization,
+ 'get_organization', 'organization',
+ extra_request_keys={
+ 'name':'name__icontains',
+ 'organization_type':'organization_type__pk__in',
+ },)
+new_author = new_item(models.Author, forms.AuthorForm)
show_person = show_item(models.Person, 'person')
get_person = get_item(models.Person,
'get_person', 'person',
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index ec684650f..55c9d0d9d 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -839,6 +839,12 @@ class PersonWizard(Wizard):
class PersonModifWizard(PersonWizard):
modification = True
+class OrganizationWizard(Wizard):
+ model = models.Organization
+
+class OrganizationModifWizard(OrganizationWizard):
+ modification = True
+
class AccountWizard(Wizard):
model = models.Person
def get_formated_datas(self, forms):