Added organization view and templates.
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 31 Jan 2009 18:55:34 +0000
changeset 1126 4fc86db70a76
parent 1125 c6e8e3573fa2
child 1127 69a9134c5c7e
Added organization view and templates. Also added TODO's so it's clear what still needs to be done to make this work. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/templates/soc/organization/list/heading.html
app/soc/templates/soc/organization/list/row.html
app/soc/templates/soc/organization/public.html
app/soc/views/models/organization.py
app/soc/views/sitemap/build.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/organization/list/heading.html	Sat Jan 31 18:55:34 2009 +0000
@@ -0,0 +1,6 @@
+<tr align="left">
+  <th class="first" align="right">Name</th>
+  <th>Program ID</th>
+  <th>Link ID</th>
+  <th>Short name</th>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/organization/list/row.html	Sat Jan 31 18:55:34 2009 +0000
@@ -0,0 +1,10 @@
+<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
+onclick="document.location.href='{{ list.redirect }}'" name="name">
+  <td align="right"><div class="name"><a class="noul"
+         href="{{ list.redirect }}">{{ list.item.name }}</a>
+     </div>
+  </td>
+  <td><div class="link_id">{{ list.item.scope.key.name }}</a></div></td>
+  <td><div class="link_id">{{ list.item.link_id }}</a></div></td>
+  <td><div class="short_name">{{ list.item.short_name }}</div></td>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/organization/public.html	Sat Jan 31 18:55:34 2009 +0000
@@ -0,0 +1,40 @@
+{% extends "soc/base.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+
+{% block header_title %}
+{{ page_name }} for {{ entity.name }}
+{% endblock %}
+
+{% block body %}
+<p>
+ <table>
+  {% readonly_field_as_table_row entity.fields.name.label entity.name %}
+  {% readonly_field_as_table_row entity.fields.home_page.label entity.home_page %}
+  {% readonly_field_as_table_row entity.fields.description.label entity.description %}
+  {% readonly_field_as_table_row entity.fields.contact_street.label entity.contact_street %}
+  {% readonly_field_as_table_row entity.fields.contact_city.label entity.contact_city %}
+  {% readonly_field_as_table_row entity.fields.contact_state.label entity.contact_state %}
+  {% readonly_field_as_table_row entity.fields.contact_country.label entity.contact_country %}
+  {% readonly_field_as_table_row entity.fields.contact_postalcode.label entity.contact_postalcode %}
+  {% readonly_field_as_table_row entity.fields.phone.label entity.phone %}
+  {% readonly_field_as_table_row entity.fields.shipping_street.label entity.shipping_street %}
+  {% readonly_field_as_table_row entity.fields.shipping_city.label entity.shipping_city %}
+  {% readonly_field_as_table_row entity.fields.shipping_state.label entity.shipping_state %}
+  {% readonly_field_as_table_row entity.fields.shipping_country.label entity.shipping_country %}
+  {% readonly_field_as_table_row entity.fields.shipping_postalcode.label entity.shipping_postalcode %}
+ </table>
+</p>
+{% endblock %}
--- a/app/soc/views/models/organization.py	Sat Jan 31 18:44:00 2009 +0000
+++ b/app/soc/views/models/organization.py	Sat Jan 31 18:55:34 2009 +0000
@@ -19,6 +19,7 @@
 
 __authors__ = [
     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+    '"Lennard de Rijk" <ljvderijk@gmail.com>',
   ]
 
 
@@ -26,6 +27,7 @@
 
 from soc.logic import cleaning
 from soc.logic import dicts
+from soc.views.helper import access
 from soc.views.helper import redirects
 from soc.views.models import group
 from soc.views.models import program as program_view
@@ -46,6 +48,18 @@
       original_params: a dict with params for this View
     """
 
+    # TODO do the proper access checks
+    rights = access.Checker(params)
+    rights['create'] = ['checkIsDeveloper']
+    rights['edit'] = ['checkIsDeveloper']
+    rights['delete'] = ['checkIsDeveloper']
+    rights['home'] = ['allow']
+    rights['list'] = ['checkIsDeveloper']
+    rights['list_requests'] = ['checkIsDeveloper']
+    rights['list_roles'] = ['checkIsDeveloper']
+    # TODO(ljvderijk) implement Org application process
+    #rights['applicant'] = ['checkIsDeveloper']
+
     new_params = {}
     new_params['logic'] = soc.logic.models.organization.logic
 
@@ -54,7 +68,13 @@
 
     new_params['name'] = "Organization"
     new_params['url_name'] = "org"
+    new_params['sidebar_grouping'] = 'Organizations'
 
+    new_params['public_template'] = 'soc/organization/public.html'
+    new_params['list_row'] = 'soc/organization/list/row.html'
+    new_params['list_heading'] = 'soc/organization/list/heading.html'
+
+    #TODO(ljvderijk) add cleaning methods to not overwrite existing orgs
     new_params['create_extra_dynafields'] = {
         'scope_path': forms.CharField(widget=forms.HiddenInput,
                                    required=True),
@@ -65,13 +85,19 @@
 
     super(View, self).__init__(params=params)
 
+    # TODO(ljvderijk) define several menu items for organizations
+    #def _getExtraMenuItems(self, role_description, params=None):
+
 
 view = View()
 
 create = view.create
 delete = view.delete
 edit = view.edit
+home = view.home
 list = view.list
+list_requests = view.listRequests
+list_roles = view.listRoles
 public = view.public
 export = view.export
 pick = view.pick
--- a/app/soc/views/sitemap/build.py	Sat Jan 31 18:44:00 2009 +0000
+++ b/app/soc/views/sitemap/build.py	Sat Jan 31 18:55:34 2009 +0000
@@ -32,6 +32,7 @@
 from soc.views.models import host
 from soc.views.models import notification
 from soc.views.models import organization
+from soc.views.models import org_admin
 from soc.views.models import program
 from soc.views.models import request
 from soc.views.models import site
@@ -60,6 +61,7 @@
 sidebar.addMenu(program.view.getSidebarMenus)
 sidebar.addMenu(program.view.getExtraMenus)
 sidebar.addMenu(organization.view.getSidebarMenus)
+sidebar.addMenu(org_admin.view.getSidebarMenus)
 
 sitemap.addPages(club.view.getDjangoURLPatterns())
 sitemap.addPages(club_admin.view.getDjangoURLPatterns())
@@ -69,6 +71,7 @@
 sitemap.addPages(host.view.getDjangoURLPatterns())
 sitemap.addPages(notification.view.getDjangoURLPatterns())
 sitemap.addPages(organization.view.getDjangoURLPatterns())
+sitemap.addPages(org_admin.view.getDjangoURLPatterns())
 sitemap.addPages(program.view.getDjangoURLPatterns())
 sitemap.addPages(request.view.getDjangoURLPatterns())
 sitemap.addPages(site.view.getDjangoURLPatterns())