Permalink
Browse files

Add license selector to upload form, fixing #211

  • Loading branch information...
1 parent 65735c2 commit e31b3d277b0ab98b19dd3197dc868e93023868bb @epoz epoz committed Apr 19, 2012
Showing with 31 additions and 2 deletions.
  1. +2 −1 bibserver/ingest.py
  2. +3 −1 bibserver/templates/tickets/view.html
  3. +23 −0 bibserver/templates/upload.html
  4. +3 −0 bibserver/web.py
View
3 bibserver/ingest.py
@@ -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'
View
4 bibserver/templates/tickets/view.html
@@ -17,6 +17,7 @@
<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>
@@ -25,9 +26,10 @@
{% 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>
View
23 bibserver/templates/upload.html
@@ -20,6 +20,29 @@
<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>
View
3 bibserver/web.py
@@ -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'):

0 comments on commit e31b3d2

Please sign in to comment.