Author: croberts
Date: 2012-10-12 20:53:09 +0000 (Fri, 12 Oct 2012)
New Revision: 5508
Modified:
trunk/cumin/python/cumin/grid/negotiator.py
trunk/cumin/python/cumin/grid/negotiator.strings
Log:
For BZ 635207. If a quota being edited has subshares, there will now be links to edit
those subshares on the Quota editing form.
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2012-10-11 16:11:21 UTC (rev 5507)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2012-10-12 20:53:09 UTC (rev 5508)
@@ -123,7 +123,21 @@
self.info.set(session, info)
return info[group]['has_child']
+
+ def get_children(self, session, group):
+ info = self.get_config_info(session)
+ try:
+ return info[group]['children']
+ except KeyError:
+ info[group]['children'] = list()
+ for key in info:
+ if key.startswith(group+"."):
+ info[group]['children'].append(key)
+
+ self.info.set(session, info)
+ return info[group]['children']
+
def get_parent(self, session, group):
info = self.get_config_info(session)
@@ -287,6 +301,8 @@
return "Percent"
def render_all_group_values(self, session):
+ all_groups = self.group_helper.get_config_info(session)
+ self.group_helper.get_config_for_groups(session, "GROUP_QUOTA_DYNAMIC",
all_groups)
group_leader = self.group_leader.get(session)
groups = self.group_helper.get_siblings(session, group_leader)
info = self.group_helper.get_config_for_groups(session,
"GROUP_QUOTA_DYNAMIC", groups)
@@ -404,6 +420,28 @@
return None
return str(pri / 100)
+
+ def render_subshares(self, session):
+ links = ""
+ common_parent = self.group_leader.get(session)
+ subshares = self.group_helper.get_children(session,
self.group_leader.get(session))
+ for share in subshares:
+ if self.group_helper.get_parent(session, share) == common_parent:
+ links += '''<li><a
href="%s">%s</a></li>''' %
(self.task.get_href_group(session, share) , share)
+ return "%s" % links
+
+ def render_subshares_title(self, session):
+ subshares = self.group_helper.get_children(session,
self.group_leader.get(session))
+ if len(subshares) > 0:
+ current_node = self.group_leader.get(session)
+ breadcrumbs = ["""<a
href="%s">%s</a>""" % (self.task.get_href_group(session,
current_node), current_node)]
+ while self.group_helper.get_parent(session, current_node) != "":
+ breadcrumbs.append("""<a
href="%s">%s</a>""" % (self.task.get_href_group(session,
self.group_helper.get_parent(session, current_node)),
self.group_helper.get_parent(session, current_node)))
+ current_node = self.group_helper.get_parent(session, current_node)
+ breadcrumbs.reverse()
+ return "Edit subshares for %s" % " >
".join(breadcrumbs)
+ else:
+ return ""
class PriorityPieChart(StatFlashChart):
def __init__(self, app, name, negotiator, group_helper, group_leader):
@@ -453,6 +491,7 @@
class NegotiatorEditDynamicQuota(NegotiatorGroupTask):
def __init__(self, app, frame):
super(NegotiatorEditDynamicQuota, self).__init__(app, frame)
+ self.frame = frame
self.form = EditDynamicQuotaForm(app, self.name, self)
# don't show in page summary section
@@ -470,4 +509,12 @@
negotiator = self.frame.negotiator_attribute.get(osession)
self.form.negotiator.set(session, negotiator)
+
+ def get_href_group(self, session, group):
+ task = self.frame.edit_dynamic_quota
+ nsession = session.branch()
+ task.form.group_leader.set(nsession, group)
+ url = self.form.return_url.get(session)
+ task.form.return_url.set(nsession, url)
+ return nsession.marshal()
Modified: trunk/cumin/python/cumin/grid/negotiator.strings
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.strings 2012-10-11 16:11:21 UTC (rev 5507)
+++ trunk/cumin/python/cumin/grid/negotiator.strings 2012-10-12 20:53:09 UTC (rev 5508)
@@ -15,6 +15,14 @@
</tbody>
</table>
<div><div id="holder" style="width:400px;height:250px;"
class="StatValueChart"></div></div><div
style="clear:left;"><!-- --></div>
+ <div class="subshares_title">
+ <h1>
+ {subshares_title}
+ </h1>
+ </div>
+ <div class="subshares">
+ {subshares}
+ </div>
</div>
<div class="foot">
{submit}
@@ -163,6 +171,16 @@
border: 1px solid #f00;
}
+.subshares {
+ margin-left:10px;
+}
+.subshares li {
+ list-style:none;
+}
+.subshares_title h1{
+ margin-bottom:0px;
+}
+
[EditDynamicQuotaForm.javascript]
cumin.get_quota_sum = function () {
var elems = document.forms[0].elements;