模板中判断能否分享

This commit is contained in:
virusdefender 2015-09-23 21:37:29 +08:00
parent 7b2a871f47
commit e95bf8e162

View File

@ -65,17 +65,18 @@
<div id="code-field"> <div id="code-field">
<textarea id="code-editor">{{ submission.code }}</textarea> <textarea id="code-editor">{{ submission.code }}</textarea>
</div> </div>
{% if can_share %}
<div id="share-code" class="col-lg-6 col-md-6"> <div id="share-code" class="col-lg-6 col-md-6">
{% if submission.shared %} {% if submission.shared %}
<button class="btn btn-warning" id="share-code-btn">取消分享</button> <button class="btn btn-warning" id="share-code-btn">取消分享</button>
{% else %} {% else %}
<button class="btn btn-primary" id="share-code-btn">分享我的代码</button> <button class="btn btn-primary" id="share-code-btn">分享我的代码</button>
{% endif %} {% endif %}
<textarea class="form-control" id="share-code-textarea" <textarea class="form-control" id="share-code-textarea"
{% if not submission.shared %}style="display: none" {% endif %}>{{ problem.title }} {% if not submission.shared %}style="display: none" {% endif %}>{{ problem.title }}
{{ request.build_absolute_uri }}</textarea> {{ request.build_absolute_uri }}</textarea>
</div> </div>
{% endif %}
</div> </div>
@ -102,7 +103,7 @@
url: "/api/submission/share/", url: "/api/submission/share/",
method: "post", method: "post",
data: {submission_id: location.href.split("/")[4]}, data: {submission_id: location.href.split("/")[4]},
success: function(data){ success: function (data) {
location.reload(); location.reload();
} }
}) })