Made it so the metadata editting page is only one step away from functioning
correctly.
This commit is contained in:
parent
e80596c80e
commit
9919fb08a4
@ -17,6 +17,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from itsdangerous import BadSignature
|
||||
from pyld import jsonld
|
||||
from werkzeug.exceptions import Forbidden
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
@ -438,7 +439,20 @@ def change_email(request):
|
||||
@require_active_login
|
||||
@get_media_entry_by_id
|
||||
def edit_metadata(request, media):
|
||||
form = forms.EditMetaDataForm()
|
||||
form = forms.EditMetaDataForm(request.form)
|
||||
if request.method == "POST" and form.validate():
|
||||
context = dict([(row['identifier'],row['value'])
|
||||
for row in form.context.data])
|
||||
metadata_dict = dict([(row['identifier'],row['value'])
|
||||
for row in form.media_metadata.data])
|
||||
# TODO VALIDATE THIS BEFORE WE ENTER IT
|
||||
# validate(metadata_dict)
|
||||
# validate(context)
|
||||
json_ld_metadata = jsonld.compact(metadata_dict, context)
|
||||
# media.media_metadata = json_ld_metadata
|
||||
# media.save()
|
||||
return redirect_obj(request, media)
|
||||
|
||||
if media.media_metadata:
|
||||
for row in media.media_metadata.iteritems():
|
||||
if row[0] == "@context": continue
|
||||
|
@ -41,7 +41,7 @@
|
||||
$('table'+list_id+' tr').each(function(row){
|
||||
id_input = $(this).find('td').find('input');
|
||||
value_input = $(this).find('td').next().find('input');
|
||||
if ((value_input.attr('value') == "") &&
|
||||
if ((value_input.attr('value') == "") &&
|
||||
(id_input.attr('value') == "")) {
|
||||
$(this).remove();
|
||||
}
|
||||
@ -52,13 +52,13 @@
|
||||
var context_lines = {{ form.context | length }};
|
||||
var metadata_lines = {{ form.media_metadata | length }};
|
||||
$("#add_new_metadata_row").click(function(){
|
||||
add_new_row("#metadata_list",
|
||||
add_new_row("#metadata_list",
|
||||
metadata_lines,
|
||||
'media_metadata-');
|
||||
metadata_lines += 1;
|
||||
})
|
||||
$("#add_new_context_row").click(function(){
|
||||
add_new_row("#context_list",
|
||||
add_new_row("#context_list",
|
||||
context_lines,
|
||||
'context-');
|
||||
context_lines += 1;
|
||||
@ -115,7 +115,7 @@
|
||||
<td><input type=button value="{% trans %}Add new Row{% endtrans %}"
|
||||
class="button_action" id="add_new_metadata_row" />
|
||||
</td>
|
||||
<td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
|
||||
<td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
|
||||
class="button_action_highlight" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -125,5 +125,5 @@
|
||||
</table>
|
||||
{{ csrf_token }}
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock mediagoblin_content %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user