Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add license selector to upload form, fixing #211
  • Loading branch information
epoz committed Apr 19, 2012
1 parent 65735c2 commit e31b3d2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bibserver/ingest.py
Expand Up @@ -107,7 +107,8 @@ def index(ticket):
'collection': util.slugify(ticket['collection']),
'description': ticket.get('description'),
'source': ticket['source_url'],
'format': ticket['format']
'format': ticket['format'],
'license': ticket.get('license', u"Not specified"),
}
collection, records = importer.upload(open(in_path), collection)
ticket['state'] = 'done'
Expand Down
4 changes: 3 additions & 1 deletion bibserver/templates/tickets/view.html
Expand Up @@ -17,6 +17,7 @@ <h1>Upload Tickets</h1>
<thead><tr>
<th><a href="/ticket/?sort=state">State</a></th>
<th><a href="/ticket/?sort=owner">Owner</a></th>
<th><a href="/ticket/?sort=collection">Collection</a></th>
<th><a href="/ticket/?sort=_last_modified">Timestamp</a></th>
<th><a href="/ticket/?sort=format">Format</a></th>
<th>Source</th><th>&nbsp;</th><th>&nbsp;</th>
Expand All @@ -25,9 +26,10 @@ <h1>Upload Tickets</h1>
{% for t in ingest_tickets %}

<tbody><tr>
<td><a title="Click to view more details" href="/ticket/{{t.id}}">{{t.state}}</a>{% if (t.id == ticket.id) and (t.state != 'new') and (t.owner == current_user._id) %}<br/><a class="btn reset_ticket" href="{{ticket.id}}">Reset</a>{% endif%}
<td><a title="Click to view more details" href="/ticket/{{t.id}}">{{t.state}}</a>{% if (t.id == ticket.id) and (t.state != 'new') and ((t.owner == current_user._id) or current_user.is_super) %}<br/><a class="btn reset_ticket" href="{{ticket.id}}">Reset</a>{% endif%}
</td>
<td>{{t.owner}}</td>
<td>{{t.collection}}</td>
<td>{{t._last_modified}}</td>
<td>{{t.format}}</td>
<td>{% if t.source_url.startswith('http') %}<a href="{{t.source_url}}">Source URL</a>
Expand Down
23 changes: 23 additions & 0 deletions bibserver/templates/upload.html
Expand Up @@ -20,6 +20,29 @@ <h2>Upload your collection</h2>
<br /><span class="upload_label">name your collection:</span> <input id="collection" type="text" name="collection" />

<br /><br /><span class="upload_label">provide a description:</span> <textarea id="description" name="description"></textarea>

<div>
<p>What is the license for this data?</p>
<select id="license_choice" name="license">
</select>
<script type="text/javascript" charset="utf-8">
// Retrieve the available license options from http://licenses.opendefinition.org/
jQuery.ajax({
url:'http://licenses.opendefinition.org/licenses/jsonp/ckan.js',
dataType: 'jsonp',
// you *must* set the callback function to be licenses_callback
jsonpCallback: 'license_callback',
success: function(data) {
var options = '';
for(var idx=0; idx<data.length; idx++) {
var o = '<option value="' + data[idx].url + '">' + data[idx].title + '</option>';
options += o;
}
jQuery('#license_choice').html(options);
}
});
</script>
</div>

<div id="fileformat">
<p>We could not identify the file format, please specify:</p>
Expand Down
3 changes: 3 additions & 0 deletions bibserver/web.py
Expand Up @@ -153,6 +153,9 @@ def post(self):
if only_parse:
ticket['only_parse'] = True

license = request.values.get('license')
if license: ticket['license'] = license

# If the user is uploading a file, update the ticket with the 'downloaded' file
# And correct source
if request.files.get('upfile'):
Expand Down

0 comments on commit e31b3d2

Please sign in to comment.