You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by st...@apache.org on 2013/02/25 21:53:41 UTC
[1/3] git commit: organization simone
organization simone
Signed-off-by: Stefano Invernizzi <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1cf0afc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1cf0afc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1cf0afc4
Branch: refs/heads/sg/5566
Commit: 1cf0afc48f06619ea05c6c411ed9b8f1c090af57
Parents: c3f622e
Author: Simone Gatti <si...@gmail.com>
Authored: Sun Feb 24 17:48:48 2013 +0100
Committer: Stefano Invernizzi <st...@apache.org>
Committed: Mon Feb 25 21:38:56 2013 +0100
----------------------------------------------------------------------
Allura/allura/controllers/basetest_project_root.py | 4 ++-
Allura/allura/controllers/root.py | 5 +++
.../ext/user_profile/templates/user_index.html | 22 +++++++++++++++
Allura/allura/lib/app_globals.py | 3 ++
Allura/allura/model/auth.py | 13 +++++++++
Allura/allura/model/project.py | 4 +++
Allura/allura/nf/allura/css/allura.css | 12 +++++++-
.../templates/jinja_master/theme_macros.html | 3 ++
Allura/allura/websetup/bootstrap.py | 6 ++++
Allura/development.ini | 1 +
10 files changed, 71 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/controllers/basetest_project_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index 5626019..4a70465 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -6,7 +6,7 @@ from urllib import unquote
import pkg_resources
from pylons import tmpl_context as c
-from pylons import request, response
+from pylons import request, response, g
from webob import exc
from tg import expose
from tg.decorators import without_trailing_slash
@@ -59,6 +59,8 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
self.security = SecurityTests()
for attr in ('index', 'browse', 'auth', 'nf', 'error'):
setattr(self, attr, getattr(proxy_root, attr))
+ if g.show_organizations:
+ self.organization = proxy_root.organization
self.gsearch = proxy_root.search
self.rest = RestController()
super(BasetestProjectRootController, self).__init__()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/controllers/root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/root.py b/Allura/allura/controllers/root.py
index 69c80ec..9c2b2ba 100644
--- a/Allura/allura/controllers/root.py
+++ b/Allura/allura/controllers/root.py
@@ -69,6 +69,11 @@ class RootController(WsgiDispatchController):
if n and not n.url_prefix.startswith('//'):
n.bind_controller(self)
self.browse = ProjectBrowseController()
+
+ ep = g.entry_points["organizations"].get('organization')
+ if ep and g.show_organizations:
+ self.organization = ep().root
+
super(RootController, self).__init__()
def _setup_request(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/ext/user_profile/templates/user_index.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/templates/user_index.html b/Allura/allura/ext/user_profile/templates/user_index.html
index 2614953..4e0856e 100644
--- a/Allura/allura/ext/user_profile/templates/user_index.html
+++ b/Allura/allura/ext/user_profile/templates/user_index.html
@@ -236,6 +236,28 @@
</div>
</div>
+ {% if user.get_current_organizations() or user.get_past_organizations() %}
+ <div class="grid-24">
+ <div class="grid-24" style="margin:0;"><b>Organizations</b></div>
+ <div class="grid-24" style="margin-top:5px;margin-bottom:5px;">
+ <ul>
+ {% for org in user.get_current_organizations() %}
+ <li>
+ {{org.role.capitalize()}} at <a href="{{org.organization.url()}}">{{org.organization.fullname}}</a>
+ from {{org.startdate.strftime('%d %B %Y')}}
+ </li>
+ {% endfor %}
+ {% for org in user.get_past_organizations() %}
+ <li>
+ {{org.role.capitalize()}} at <a href="{{org.organization.url()}}">{{org.organization.fullname}}</a>
+ from {{org.startdate.strftime('%d %B %Y')}} to {{org.closeddate.strftime('%d %B %Y')}}
+ </li>
+ {% endfor %}
+ <ul>
+ </div>
+ </div>
+ {%endif%}
+
{% if c.user.username == user.username %}
<div class="address-list grid-18">
<b>Email Addresses</b>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 14522aa..ad1f62b 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -165,11 +165,14 @@ class Globals(object):
theme=_cache_eps('allura.theme'),
user_prefs=_cache_eps('allura.user_prefs'),
spam=_cache_eps('allura.spam'),
+ organizations=_cache_eps('allura.organization'),
)
# Zarkov logger
self._zarkov = None
+ self.show_organizations = config.get('organizations.enable')=='true'
+
@LazyProperty
def spam_checker(self):
"""Return a SpamFilter implementation.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 8df4a58..6abbc59 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -331,6 +331,9 @@ class User(MappedClass, ActivityNode, ActivityObject):
level = S.OneOf('low', 'high', 'medium'),
comment=str)])
+ #Organizations
+ memberships = RelationProperty('Membership')
+
@property
def activity_name(self):
return self.display_name or self.username
@@ -341,6 +344,16 @@ class User(MappedClass, ActivityNode, ActivityObject):
def set_pref(self, pref_name, pref_value):
return plugin.UserPreferencesProvider.get().set_pref(self, pref_name, pref_value)
+ def get_current_organizations(self):
+ if hasattr(self, 'memberships'):
+ return [m for m in self.memberships if m.status=='active']
+ return []
+
+ def get_past_organizations(self):
+ if hasattr(self, 'memberships'):
+ return [m for m in self.memberships if m.status=='closed']
+ return []
+
def add_socialnetwork(self, socialnetwork, accounturl):
if socialnetwork == 'Twitter' and not accounturl.startswith('http'):
accounturl = 'http://twitter.com/%s' % accounturl.replace('@', '')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 93f8257..9b24036 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -166,6 +166,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
tracking_id = FieldProperty(str, if_missing='')
is_nbhd_project=FieldProperty(bool, if_missing=False)
+ organizations=RelationProperty('ProjectInvolvement')
+
# transient properties
notifications_disabled = False
@@ -718,6 +720,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
apps = [('admin', 'admin', 'Admin'),
('search', 'search', 'Search'),
('activity', 'activity', 'Activity')]
+ if g.show_organizations:
+ apps+=[('organizationstool', 'organizationstool', 'Organizations')]
with h.push_config(c, project=self, user=users[0]):
# Install default named roles (#78)
root_project_id=self.root_project._id
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/nf/allura/css/allura.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/allura.css b/Allura/allura/nf/allura/css/allura.css
index 1f32750..224ad0a 100644
--- a/Allura/allura/nf/allura/css/allura.css
+++ b/Allura/allura/nf/allura/css/allura.css
@@ -91,6 +91,11 @@ b.ico.ico-vote-down { background-image: url('../images/vote_down.png'); }
background-repeat: no-repeat;
}
+.ui-icon-tool-organizationstool {
+ background-image: url("../images/org_24.png");
+ background-repeat: no-repeat;
+}
+
.ui-icon-tool-chat {
background-image: url("../images/chat_24.png");
background-repeat: no-repeat;
@@ -139,7 +144,12 @@ b.ico.ico-vote-down { background-image: url('../images/vote_down.png'); }
#top_nav .ui-icon-tool-chat {
background-image: url("../images/chat_32.png");
}
-
+#top_nav .ui-icon-tool-organizationstool {
+ background-image: url("../images/org_32.png");
+}
+.big_icon.ui-icon-tool-organizationstool {
+ background-image: url("../images/org_48.png");
+}
.big_icon.ui-icon-tool-home {
background-image: url("../images/home_48.png");
}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index 655b67b..ebb85fe 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -3,6 +3,9 @@
<div class="wrapper">
<nav>
{% if c.user._id %}
+ {%if g.show_organizations %}
+ <a href="/organization/">Organizations</a>
+ {% endif %}
<a href="/auth/prefs/">Account</a>
<a href="{{c.user.url()}}">{{name}}</a>
<a href="{{logout_url}}">Log Out</a>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/allura/websetup/bootstrap.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index 9614b99..59d240d 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -6,6 +6,7 @@ import logging
import shutil
from collections import defaultdict
from datetime import datetime
+import pkg_resources
import tg
from pylons import tmpl_context as c, app_globals as g
@@ -175,6 +176,11 @@ def bootstrap(command, conf, vars):
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
+ ep = pkg_resources.get_entry_info(
+ 'forgeorganization', 'allura.organization', 'organization')
+ if ep is not None:
+ ep.load().bootstrap()
+
def wipe_database():
conn = M.main_doc_session.bind.conn
create_trove_categories = CreateTroveCategoriesCommand('create_trove_categories')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1cf0afc4/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index ae550ae..1f04fc5 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -122,6 +122,7 @@ gitweb.cgi = /usr/lib/cgi-bin/gitweb.cgi
scm.repos.root = /tmp
trovecategories.enableediting = true
+organizations.enable = true
# ActivityStream
activitystream.master = mongodb://127.0.0.1:27017