signed edit data is now a dictionary
This commit is contained in:
parent
9d08d92844
commit
817056f235
2 changed files with 60 additions and 19 deletions
|
@ -61,10 +61,23 @@
|
||||||
|
|
||||||
<h3>Your Edit</h3>
|
<h3>Your Edit</h3>
|
||||||
<p><strong>Map Package:</strong> {{ package_name }}</p>
|
<p><strong>Map Package:</strong> {{ package_name }}</p>
|
||||||
{% if file_contents %}
|
<p>
|
||||||
<p><strong>New content for file:</strong> <code>{{ file_path }}</code></p>
|
<strong>
|
||||||
<pre>{{ file_contents }}</pre>
|
{% if action == 'create' %}
|
||||||
{% else %}
|
Create file:
|
||||||
<p><strong>Delete file:</strong> <code>{{ file_path }}</code></p>
|
{% elif action == 'edit' %}
|
||||||
|
Edit file:
|
||||||
|
{% elif action == 'delete' %}
|
||||||
|
Delete file:
|
||||||
|
{% endif %}
|
||||||
|
</strong>
|
||||||
|
<code>{{ file_path }}</code>
|
||||||
|
</p>
|
||||||
|
<p><strong>Parent commit id:</strong> <code>{{ commit_id }}</code></p>
|
||||||
|
{% if action != 'delete' %}
|
||||||
|
<p>
|
||||||
|
<strong>New file contents:</strong>
|
||||||
|
<pre>{{ file_contents }}</pre>
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -36,7 +36,15 @@ def add_feature(request, feature_type):
|
||||||
commit_msg = 'Added %s: %s' % (str(feature_type.title).lower(), title_en)
|
commit_msg = 'Added %s: %s' % (str(feature_type.title).lower(), title_en)
|
||||||
activate(language)
|
activate(language)
|
||||||
return render(request, 'editor/feature_success.html', {
|
return render(request, 'editor/feature_success.html', {
|
||||||
'data': signing.dumps((feature.package.name, feature.tofilename(), content, commit_msg))
|
'data': signing.dumps({
|
||||||
|
'type': 'editor.edit',
|
||||||
|
'action': 'create',
|
||||||
|
'package_name': feature.package.name,
|
||||||
|
'commit_id': feature.package.commit_id,
|
||||||
|
'commit_msg': commit_msg,
|
||||||
|
'file_path': feature.tofilename(),
|
||||||
|
'content': content,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
feature.save()
|
feature.save()
|
||||||
|
@ -68,7 +76,14 @@ def edit_feature(request, name):
|
||||||
commit_msg = 'Deleted %s: %s' % (str(feature_type.title).lower(), title_en)
|
commit_msg = 'Deleted %s: %s' % (str(feature_type.title).lower(), title_en)
|
||||||
activate(language)
|
activate(language)
|
||||||
return render(request, 'editor/feature_success.html', {
|
return render(request, 'editor/feature_success.html', {
|
||||||
'data': signing.dumps((feature.package.name, feature.tofilename(), None, commit_msg))
|
'data': signing.dumps({
|
||||||
|
'type': 'editor.edit',
|
||||||
|
'action': 'delete',
|
||||||
|
'package_name': feature.package.name,
|
||||||
|
'commit_id': feature.package.commit_id,
|
||||||
|
'commit_msg': commit_msg,
|
||||||
|
'file_path': feature.tofilename(),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
feature.delete()
|
feature.delete()
|
||||||
|
@ -96,7 +111,15 @@ def edit_feature(request, name):
|
||||||
commit_msg = 'Updated %s: %s' % (str(feature_type.title).lower(), title_en)
|
commit_msg = 'Updated %s: %s' % (str(feature_type.title).lower(), title_en)
|
||||||
activate(language)
|
activate(language)
|
||||||
return render(request, 'editor/feature_success.html', {
|
return render(request, 'editor/feature_success.html', {
|
||||||
'data': signing.dumps((feature.package.name, feature.tofilename(), content, commit_msg))
|
'data': signing.dumps({
|
||||||
|
'type': 'editor.edit',
|
||||||
|
'action': 'edit',
|
||||||
|
'package_name': feature.package.name,
|
||||||
|
'commit_id': feature.package.commit_id,
|
||||||
|
'commit_msg': commit_msg,
|
||||||
|
'file_path': feature.tofilename(),
|
||||||
|
'content': content,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
feature.save()
|
feature.save()
|
||||||
|
@ -117,11 +140,12 @@ def edit_feature(request, name):
|
||||||
def finalize(request):
|
def finalize(request):
|
||||||
if 'data' not in request.POST:
|
if 'data' not in request.POST:
|
||||||
raise SuspiciousOperation('Missing data.')
|
raise SuspiciousOperation('Missing data.')
|
||||||
data = request.POST['data']
|
data = signing.loads(request.POST['data'])
|
||||||
|
|
||||||
package_name, file_path, file_contents, commit_msg = signing.loads(data)
|
if data['type'] != 'editor.edit':
|
||||||
|
raise SuspiciousOperation('Wrong data type.')
|
||||||
|
|
||||||
package = Package.objects.filter(name=package_name).first()
|
package = Package.objects.filter(name=data['package_name']).first()
|
||||||
hoster = None
|
hoster = None
|
||||||
if package is not None:
|
if package is not None:
|
||||||
hoster = get_hoster_for_package(package)
|
hoster = get_hoster_for_package(package)
|
||||||
|
@ -137,17 +161,19 @@ def finalize(request):
|
||||||
if form.is_valid() and hoster_state == 'logged_in':
|
if form.is_valid() and hoster_state == 'logged_in':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
form = CommitForm({'commit_msg': commit_msg})
|
form = CommitForm({'commit_msg': data['commit_msg']})
|
||||||
|
|
||||||
return render(request, 'editor/finalize.html', {
|
return render(request, 'editor/finalize.html', {
|
||||||
'data': data,
|
'data': request.POST['data'],
|
||||||
|
'action': data['action'],
|
||||||
|
'commit_id': data['commit_id'],
|
||||||
'commit_form': form,
|
'commit_form': form,
|
||||||
'package_name': package_name,
|
'package_name': data['package_name'],
|
||||||
'hoster': hoster,
|
'hoster': hoster,
|
||||||
'hoster_state': hoster_state,
|
'hoster_state': hoster_state,
|
||||||
'hoster_error': hoster_error,
|
'hoster_error': hoster_error,
|
||||||
'file_path': file_path,
|
'file_path': data['file_path'],
|
||||||
'file_contents': file_contents
|
'file_contents': data.get('content')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,10 +186,12 @@ def finalize_oauth_progress(request):
|
||||||
def finalize_oauth_redirect(request):
|
def finalize_oauth_redirect(request):
|
||||||
if 'data' not in request.POST:
|
if 'data' not in request.POST:
|
||||||
raise SuspiciousOperation('Missing data.')
|
raise SuspiciousOperation('Missing data.')
|
||||||
data = request.POST['data']
|
data = signing.loads(request.POST['data'])
|
||||||
|
|
||||||
package_name, file_path, file_contents, commit_msg = signing.loads(data)
|
if data['type'] != 'editor.edit':
|
||||||
package = Package.objects.filter(name=package_name).first()
|
raise SuspiciousOperation('Wrong data type.')
|
||||||
|
|
||||||
|
package = Package.objects.filter(name=data['package_name']).first()
|
||||||
hoster = None
|
hoster = None
|
||||||
if package is not None:
|
if package is not None:
|
||||||
hoster = get_hoster_for_package(package)
|
hoster = get_hoster_for_package(package)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue