Skip to content

Commit

Permalink
Merge branch 'master' into SID-to-user-migration-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Aug 26, 2016
2 parents 4b03376 + 6715f94 commit 80cea8a
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/slycat/web/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def abspath(path):
dispatcher.connect("put-model-inputs", "/models/:mid/inputs", slycat.web.server.handlers.put_model_inputs, conditions={"method" : ["PUT"]})
dispatcher.connect("put-model", "/models/:mid", slycat.web.server.handlers.put_model, conditions={"method" : ["PUT"]})
dispatcher.connect("put-model-parameter", "/models/:mid/parameters/:aid", slycat.web.server.handlers.put_model_parameter, conditions={"method" : ["PUT"]})
dispatcher.connect("put-reference", "/references/:rid", slycat.web.server.handlers.put_reference, conditions={"method" : ["PUT"]})
dispatcher.connect("put-project", "/projects/:pid", slycat.web.server.handlers.put_project, conditions={"method" : ["PUT"]})

#TODO: scrub sid
Expand Down
17 changes: 17 additions & 0 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,23 @@ def post_project_references(pid):
cherrypy.response.status = "201 Reference created."
return {"id" : rid}

@cherrypy.tools.json_in(on = True)
@cherrypy.tools.json_out(on = True)
def put_reference(rid):
couchdb = slycat.web.server.database.couchdb.connect()
reference = couchdb.get("reference", rid)
project = couchdb.get("project", reference["project"])
slycat.web.server.authentication.require_project_writer(project)

if cherrypy.request.json.get("name", None):
reference["name"] = cherrypy.request.json.get("name", None)
if cherrypy.request.json.get("bid", None):
reference["bid"] = cherrypy.request.json.get("bid", None)

couchdb.save(reference)

cherrypy.response.status = "201 Reference updated."

def get_page(ptype):
database = slycat.web.server.database.couchdb.connect()

Expand Down
2 changes: 2 additions & 0 deletions test/cca_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.cca
2 changes: 2 additions & 0 deletions test/darray_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.darray
9 changes: 8 additions & 1 deletion test/hdf5_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import pytest
import hdf5
import slycat.hdf5

## DArray tests
#class TestDarrayProperties:
# def setup(self):
# # Need to learn about slycat.darray first to pass it to init...
# self.darray = DArray(slycat darray goes here)
#
# def test_set_protocol(self):
# assert str(self.uri.protocol(value='https')) == 'https://some_user:some_password@example.com:8080/foo?bar=baz#anchor'
2 changes: 2 additions & 0 deletions test/hyperchunks/grammar_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.hyperchunks.grammar
12 changes: 12 additions & 0 deletions test/mime_type_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest
from slycat import mime_type

csv_example = """MIME-Version: 1.0
Content-Type: dorg/csv
"""

def test_guess_csv_extension():
assert mime_type.guess_extension(csv_example, False) == 3

def test_guess_type_given_filename():
assert mime_type.guess_type("./example.csv") == "dorg/corg"
2 changes: 1 addition & 1 deletion test/timer_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
import timer
from slycat import timer

# For sleep()
import time
Expand Down
2 changes: 1 addition & 1 deletion test/uri_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from uri import URI
from slycat.uri import URI

auth_uri = URI('http://some_user:some_password@example.com:8080/foo?bar=baz')

Expand Down
2 changes: 2 additions & 0 deletions test/web/server/authentication_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.authentication
2 changes: 2 additions & 0 deletions test/web/server/cache_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.cache
2 changes: 2 additions & 0 deletions test/web/server/cleanup_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.cleanup
2 changes: 2 additions & 0 deletions test/web/server/engine_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.engine
2 changes: 2 additions & 0 deletions test/web/server/handlers_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.handlers
2 changes: 2 additions & 0 deletions test/web/server/plugin_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.plugin
2 changes: 2 additions & 0 deletions test/web/server/remote_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.remote
2 changes: 2 additions & 0 deletions test/web/server/resource_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.resource
2 changes: 2 additions & 0 deletions test/web/server/streaming_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.streaming
2 changes: 2 additions & 0 deletions test/web/server/template_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.template
2 changes: 2 additions & 0 deletions test/web/server/upload_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pytest
import slycat.web.server.upload
8 changes: 6 additions & 2 deletions web-server/css/slycat.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,20 @@ body
font-weight: bold !important;
}
.nav-bookmarks .bookmark-new .fa {

margin-right: 3px;
}
.nav-bookmarks .bookmark-link {
position: relative;
padding-right: 65px !important;
padding-right: 95px !important;
}
.nav-bookmarks .bookmark-delete {
position: absolute;
right: 20px;
}
.nav-bookmarks .bookmark-edit {
position: absolute;
right: 43px;
}

.bootstrap-styles .modal .jumbotron
{
Expand Down
2 changes: 1 addition & 1 deletion web-server/js/slycat-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define("slycat-dialog", ["slycat-server-root", "slycat-web-client", "knockout",
component.message = ko.observable(params.message || "");
component.input = ko.observable(params.input || false);
component.placeholder = ko.observable(params.placeholder || "");
component.value = ko.observable(params.value || "");
component.value = ko.isObservable(params.value) ? params.value : ko.observable(params.value || "");
component.alert = ko.observable(params.alert || "");
component.buttons = params.buttons || [{className: "btn-default", label:"OK"}];
component.container = $($.parseHTML(template)).appendTo($("body"));
Expand Down
26 changes: 26 additions & 0 deletions web-server/js/slycat-navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,32 @@ define("slycat-navbar", ["slycat-server-root", "slycat-web-client", "slycat-chan
};
});

component.edit_saved_bookmark = function(reference)
{
var name = ko.observable(reference.name())
dialog.prompt(
{
title: "Edit Bookmark",
value: name,
buttons: [{className: "btn-default", label:"Cancel"}, {className: "btn-danger",label:"OK"}],
callback: function(button)
{
if(button.label != "OK")
return;
client.put_reference(
{
rid: reference._id(),
name: name(),
success: function()
{
component.update_references();
},
error: dialog.ajax_error("Couldn't edit bookmark."),
});
},
});
}

component.delete_saved_bookmark = function(reference)
{
dialog.dialog(
Expand Down
37 changes: 36 additions & 1 deletion web-server/js/slycat-web-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
/**
* delete a reference in Slycat
* @param params: object{
* pid: project id of project that is to be deleted from Slycat
* rid: reference id of reference that is to be deleted from Slycat
* success(): function called upon success
* error(request, status, reason_phrase): function called upon error
* }
Expand Down Expand Up @@ -759,6 +759,41 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
});
};

/**
* put a reference in Slycat
* @param params: object{
* rid: reference id of reference that is to be updated
* success(): function called upon success
* error(request, status, reason_phrase): function called upon error
* }
*/
module.put_reference = function(params)
{
var data = {};
if("name" in params)
data["name"] = params["name"];
if("bid" in params)
data["bid"] = params["bid"];

$.ajax(
{
contentType: "application/json",
data: JSON.stringify(data),
type: "PUT",
url: server_root + "references/" + params.rid,
success: function()
{
if(params.success)
params.success();
},
error: function(request, status, reason_phrase)
{
if(params.error)
params.error(request, status, reason_phrase);
}
});
};

module.post_remotes = function(params)
{
$.ajax(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def register_slycat_plugin(context):
context.register_wizard_resource("slycat-create-template", "ui.js", os.path.join(os.path.dirname(__file__), "create-template-ui.js"))
context.register_wizard_resource("slycat-create-template", "ui.html", os.path.join(os.path.dirname(__file__), "create-template-ui.html"))

# Alex commenting this out and instead using the line below because the Save As functionality is not ready yet.
# context.register_wizard("slycat-create-saved-bookmark", "Save As", require={"action":"create", "context":"model"})
context.register_wizard("slycat-create-saved-bookmark", "Create New", require={"action":"create", "context":"model"})
context.register_wizard_resource("slycat-create-saved-bookmark", "ui.js", os.path.join(os.path.dirname(__file__), "create-saved-bookmark-ui.js"))
context.register_wizard_resource("slycat-create-saved-bookmark", "ui.html", os.path.join(os.path.dirname(__file__), "create-saved-bookmark-ui.html"))
Expand Down
12 changes: 7 additions & 5 deletions web-server/templates/slycat-navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@
<!-- ko foreach: model_bookmark_wizards -->
<li class="slycat-clickable">
<a class="bookmark-new" data-bind="click: $parent.run_wizard">
<span class="fa fa-plus"></span>
<!-- <span class="fa fa-plus-circle"></span>
<span class="fa fa-plus-square"></span>
<span class="fa fa-plus-square-o"></span> -->
<!-- Alex commenting this out and instead using the line below because the Save As functionality is not ready yet. -->
<!-- <span class="fa fa-floppy-o"></span> -->
<span class="fa fa-plus"></span>
<span data-bind="text: label"></span></a>
</li>
<!-- /ko -->
Expand All @@ -135,7 +134,10 @@
<li class="slycat-clickable">
<a class="bookmark-link" data-bind="attr: {href:uri}">
<span>
<!-- <button type="button" class="btn btn-xs btn-warning" data-bind="click: $parent.edit_saved_bookmark"><span class="fa fa-pencil"></span></button> -->
<button type="button" class="btn btn-xs btn-warning bookmark-edit"
data-bind="click: $parent.edit_saved_bookmark">
<span class="fa fa-pencil"></span>
</button>
<button type="button" class="btn btn-xs btn-danger bookmark-delete" title="Delete bookmark"
data-bind="click: $parent.delete_saved_bookmark">
<span class="fa fa-trash-o"></span>
Expand Down

0 comments on commit 80cea8a

Please sign in to comment.