Added organizations
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 06 Dec 2008 14:25:24 +0000
changeset 682 187f4d95fedb
parent 681 48983ecf4665
child 683 de829096b814
Added organizations Really basic for now, next stop is to have a proper document selector for the Presences. Patch by: Sverre Rabbelier
app/soc/logic/models/organization.py
app/soc/models/organization.py
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/logic/models/organization.py	Sat Dec 06 14:25:24 2008 +0000
@@ -0,0 +1,51 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# 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.
+
+"""Organization (Model) query functions.
+"""
+
+__authors__ = [
+  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+  ]
+
+
+from soc.logic.models import base
+from soc.logic.models import group
+from soc.logic.models import program as program_logic
+
+import soc.models.group
+import soc.models.organization
+
+
+class Logic(group.Logic):
+  """Logic methods for the Organization model.
+  """
+
+  def __init__(self, model=soc.models.organization.Organization,
+               base_model=soc.models.group.Group, scope_logic=program_logic):
+    """Defines the name, key_name and model for this entity.
+    """
+
+    super(Logic, self).__init__(model=model, base_model=base_model,
+                                scope_logic=scope_logic)
+
+  # Restore base.Logic key field related methods
+  getKeyValues = base.Logic.getKeyValues
+  getKeyValuesFromFields = base.Logic.getKeyValuesFromFields
+  getKeyFieldNames = base.Logic.getKeyFieldNames
+
+
+logic = Logic()
--- a/app/soc/models/organization.py	Sat Dec 06 14:24:50 2008 +0000
+++ b/app/soc/models/organization.py	Sat Dec 06 14:25:24 2008 +0000
@@ -43,4 +43,4 @@
   #: Type short name used for example in urls
   TYPE_NAME_SHORT = 'org'
   #: Type plural name used in templates
-  TYPE_NAME_PLURAL = ugettext_lazy('Organizations')
\ No newline at end of file
+  TYPE_NAME_PLURAL = ugettext_lazy('Organizations')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/models/organization.py	Sat Dec 06 14:25:24 2008 +0000
@@ -0,0 +1,80 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# 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.
+
+"""Views for Organizations.
+"""
+
+__authors__ = [
+    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+  ]
+
+
+from google.appengine.api import users
+
+from django import forms
+
+from soc.logic import dicts
+from soc.logic import cleaning
+from soc.views.helper import redirects
+from soc.views.models import group
+from soc.views.models import program as program_view
+
+import soc.models.organization
+import soc.logic.models.organization
+
+
+class View(group.View):
+  """View methods for the Organization model.
+  """
+
+  def __init__(self, params=None):
+    """Defines the fields and methods required for the base View class
+    to provide the user with list, public, create, edit and delete views.
+
+    Params:
+      original_params: a dict with params for this View
+    """
+
+    new_params = {}
+    new_params['logic'] = soc.logic.models.organization.logic
+
+    new_params['scope_view'] = program_view
+    new_params['scope_redirect'] = redirects.getCreateRedirect
+
+    new_params['name'] = "Organization"
+    new_params['name_short'] = "Organization"
+    new_params['name_plural'] = "Organizations"
+    new_params['url_name'] = "org"
+    new_params['module_name'] = "organization"
+
+    new_params['create_extra_dynafields'] = {
+        'scope_path': forms.CharField(widget=forms.HiddenInput,
+                                   required=True),
+        'clean_link_id': cleaning.clean_link_id,
+        }
+
+    params = dicts.merge(params, new_params)
+
+    super(View, self).__init__(params=params)
+
+
+view = View()
+
+create = view.create
+delete = view.delete
+edit = view.edit
+list = view.list
+public = view.public
--- a/app/soc/views/sitemap/build.py	Sat Dec 06 14:24:50 2008 +0000
+++ b/app/soc/views/sitemap/build.py	Sat Dec 06 14:25:24 2008 +0000
@@ -26,6 +26,7 @@
 
 from soc.views.models import document
 from soc.views.models import host
+from soc.views.models import organization
 from soc.views.models import presence
 from soc.views.models import program
 from soc.views.models import request
@@ -47,6 +48,7 @@
 sidebar.addMenu(host.view.getSidebarLinks)
 sidebar.addMenu(request.view.getSidebarLinks)
 sidebar.addMenu(program.view.getSidebarLinks)
+sidebar.addMenu(organization.view.getSidebarLinks)
 
 sitemap.addPages(presence.view.getDjangoURLPatterns())
 sitemap.addPages(site.view.getDjangoURLPatterns())
@@ -57,6 +59,7 @@
 sitemap.addPages(host.view.getDjangoURLPatterns())
 sitemap.addPages(request.view.getDjangoURLPatterns())
 sitemap.addPages(program.view.getDjangoURLPatterns())
+sitemap.addPages(organization.view.getDjangoURLPatterns())
 
 
 def getPatterns():