Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Silva <sebastian@somosazucar.org>2013-09-17 15:45:16 (GMT)
committer Sebastian Silva <sebastian@somosazucar.org>2013-09-17 15:45:16 (GMT)
commit11c9b543dcc2577f2ec9ea416b4422d9fbc3bc4b (patch)
tree7a3572fdfce62de1d3521162003ed34b0dad060b
parent5ecbdba7aff3deff42177d1af1b38c716992e0a9 (diff)
Changes to support backend polish by alsroot
-rw-r--r--sugar_network_webui/app.py13
-rw-r--r--sugar_network_webui/client.py35
-rw-r--r--sugar_network_webui/cursors.py20
-rw-r--r--sugar_network_webui/objects.py1
-rw-r--r--sugar_network_webui/templates/_browser-grid.html4
-rw-r--r--sugar_network_webui/templates/_review-list.html2
-rw-r--r--sugar_network_webui/templates/context-view.html4
7 files changed, 29 insertions, 50 deletions
diff --git a/sugar_network_webui/app.py b/sugar_network_webui/app.py
index 56e87ea..95e2bb7 100644
--- a/sugar_network_webui/app.py
+++ b/sugar_network_webui/app.py
@@ -236,8 +236,7 @@ def moon(context=None):
clone = request.args.get('clone', None)
guid = context[5:] # remove "moon-" from id
- Client.call('PUT', ['context', guid], 'clone',
- content=1 if clone == 'true' else 0)
+ Client.call('PUT', ['context', guid], 'clone', clone == 'true', spawn=True)
return jsonify(clone=clone)
@@ -291,7 +290,7 @@ def new_resource(context_guid=None):
context = g.Contexts[offset]
else:
context = g.client.Context(context_guid,
- reply=['title', 'favorite', 'clone'])
+ reply=['title', 'layer'])
return render_template('resource-form.html', context=context)
@@ -617,7 +616,7 @@ def project_browser(context_guid=None):
template = 'context-view.html'
context = g.client.Context(context_guid,
reply=['guid', 'title', 'description', 'author',
- 'summary', 'favorite', 'clone', 'type'])
+ 'summary', 'layer', 'type'])
try:
session['last_context_title'] = context['title']
except NotFound:
@@ -664,7 +663,7 @@ def reviews_browser(resource_guid=None, review_guid=None):
template = 'context-view.html'
context = g.client.Context(resource_guid,
reply=['guid', 'title', 'description', 'author',
- 'summary', 'favorite', 'clone', 'type'])
+ 'summary', 'layer', 'type'])
try:
session['last_context_title'] = context['title']
except NotFound:
@@ -710,7 +709,7 @@ def solution_browser(resource_guid=None):
try:
context = g.client.Context(resource['context'],
reply=['guid', 'title', 'description', 'summary', 'author',
- 'favorite', 'clone', 'type'])
+ 'layer', 'type'])
except:
return redirect(url_for('resource_list'))
@@ -771,7 +770,7 @@ def context_resource_browser(context_guid=None, query=None):
context = resource_cursor[offset]
else:
context = g.client.Context(context_guid, reply=['guid', 'title',
- 'author', 'summary', 'description', 'favorite', 'clone', 'type'])
+ 'author', 'summary', 'description', 'layer', 'type'])
try:
session['last_context'] = context['guid']
session['last_context_title'] = context['title']
diff --git a/sugar_network_webui/client.py b/sugar_network_webui/client.py
index 88992dd..edb1da2 100644
--- a/sugar_network_webui/client.py
+++ b/sugar_network_webui/client.py
@@ -13,8 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import json
import logging
+from urllib import urlencode
from sugar_network.toolkit import coroutine
@@ -37,8 +37,11 @@ class Client(object):
_pull = None
@classmethod
- def call(cls, *args, **kwargs):
- return _call(*args, **kwargs)
+ def call(cls, method, path, cmd=None, content=None,
+ content_type='application/json',
+ **kwargs):
+ return _call(method=method, path=path, cmd=cmd, content=content,
+ content_type=content_type, **kwargs)
@classmethod
def connect(cls, callback, **condition):
@@ -54,7 +57,6 @@ class Client(object):
@classmethod
def _pull_events(cls):
for event in Client.call('GET', [], 'subscribe'):
- event = json.loads(event[6:])
for callback, condition in cls._subscriptions.items():
for key, value in condition.items():
if event.get(key) != value:
@@ -72,29 +74,8 @@ class Client(object):
def inline(self):
return self.call('GET', [], 'inline') or Client.anonymous
- def launch(self, context, command='activity', object_id=None, uri=None,
- args=None):
- """Launch context implementation.
-
- Function will call fork at the beginning. In forked process,
- it will try to choose proper implementation to execute and launch it.
-
- Execution log will be stored in `~/.sugar/PROFILE/logs` directory.
-
- :param context:
- context GUID to look for implementations
- :param command:
- command that selected implementation should support
- :param object_id:
- optional id to restore Journal object
- :param uri:
- optional uri to open; if implementation supports it
- :param args:
- optional list of arguments to pass to launching implementation
-
- """
- return self.call('GET', ['context', context], 'launch',
- object_id=object_id, uri=uri, args=args)
+ def launch(self, context, **kwargs):
+ return self.call('GET', ['context', context], 'launch', spawn=True, **kwargs)
def __getattr__(self, name):
"""Class-like object to access to a resource or call a method.
diff --git a/sugar_network_webui/cursors.py b/sugar_network_webui/cursors.py
index 52462b8..f129188 100644
--- a/sugar_network_webui/cursors.py
+++ b/sugar_network_webui/cursors.py
@@ -25,36 +25,36 @@ class Mount:
self.Contexts = self.client.Context.cursor(
type=["activity", "project"],
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
self.autocomplete_Contexts = self.client.Context.cursor(
reply=['guid', 'title'], order_by='-mtime')
self.Projects = self.client.Context.cursor(type='project',
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
self.Activities = self.client.Context.cursor(type='activity',
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
else:
self.Contexts = self.client.Context.cursor(
- clone=clone,
+ layer='clone',
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
self.autocomplete_Contexts = self.client.Context.cursor(
- clone=clone,
+ layer='clone',
reply=['guid', 'title'],
order_by='-mtime')
self.Projects = self.client.Context.cursor(type='project',
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
self.Activities = self.client.Context.cursor(type='activity',
- clone=clone,
+ layer='clone',
reply=['guid', 'type', 'title', 'author', 'summary',
- 'description', 'favorite', 'clone', 'mtime'],
+ 'description', 'layer', 'mtime'],
order_by='-mtime')
self.Questions = self.client.Feedback.cursor(type="question",
@@ -85,4 +85,4 @@ class Mount:
network_mount = Mount()
-home_mount = Mount(clone=2)
+home_mount = Mount(True)
diff --git a/sugar_network_webui/objects.py b/sugar_network_webui/objects.py
index 83186d6..62c971d 100644
--- a/sugar_network_webui/objects.py
+++ b/sugar_network_webui/objects.py
@@ -17,7 +17,6 @@ import logging
from cStringIO import StringIO
from os.path import isdir, abspath
-from sugar_network import client
from sugar_network.toolkit import enforce
from client import Client
diff --git a/sugar_network_webui/templates/_browser-grid.html b/sugar_network_webui/templates/_browser-grid.html
index 987f156..2f2a63b 100644
--- a/sugar_network_webui/templates/_browser-grid.html
+++ b/sugar_network_webui/templates/_browser-grid.html
@@ -33,14 +33,14 @@
<div class="context-label">
<span class="context-controls">
<img title="{{_('available offline')}}" id="moon-{{context['guid']}}"
- {% if context['clone'] %}
+ {% if 'clone' in context['layer'] %}
style="background-color:{{fill}}; border: 1px solid {{stroke}};"
data-clone="true"
{% endif %}
class="moon-emblem has_tooltip" src="/static/icons/moon.png"/>
<img title="{{_('favorite')}}" id="star-{{context['guid']}}"
- {% if context['favorite'] %}
+ {% if 'favorite' in context['layer'] %}
style="background-color:{{fill}}; border: 1px solid {{stroke}};"
data-favorite="true"
{% endif %}
diff --git a/sugar_network_webui/templates/_review-list.html b/sugar_network_webui/templates/_review-list.html
index fb3459b..2f597ca 100644
--- a/sugar_network_webui/templates/_review-list.html
+++ b/sugar_network_webui/templates/_review-list.html
@@ -40,7 +40,7 @@
</div>
<!--
<div class="icon-column">
- %- if item['favorite'] %
+ %- if 'favorite' in item['layer'] %
<img class="star" src="/static/icons/emblem-favorite.png"/>
%- else %
<img class="star" src="/static/icons/add-link.png"/>
diff --git a/sugar_network_webui/templates/context-view.html b/sugar_network_webui/templates/context-view.html
index 2986572..8a1ba7b 100644
--- a/sugar_network_webui/templates/context-view.html
+++ b/sugar_network_webui/templates/context-view.html
@@ -52,14 +52,14 @@
<span class="context-controls">
<img id="moon-{{context['guid']}}"
title="{{_('available offline')}}"
- {% if context['clone'] %}
+ {% if 'clone' in context['layer'] %}
style="background-color:{{fill}}; border: 1px solid {{stroke}};"
data-clone="true"
{% endif %}
class="moon-emblem has_tooltip" src="/static/icons/moon.png"/>
<img id="star-{{context['guid']}}"
title="{{_('favorite')}}"
- {% if context['favorite'] %}
+ {% if 'favorite' in context['layer'] %}
style="background-color:{{fill}}; border: 1px solid {{stroke}};"
data-favorite="true"
{% endif %}