-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UnidirectionalFeedback database and frontend impl * Add FEEDBACK_ENDPOINT & FEEDBACK_KEY * Only allows feedbacking when users could submit flags * Add feedback <a> at hub * Add "custom" logger * Use custom logger in ChallengeFeedbackURLView * Update feedback wording * Update by review suggestions * Allow setting feedback content without code change
- Loading branch information
Showing
12 changed files
with
314 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Generated by Django 4.2.16 on 2024-10-24 15:52 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("frontend", "0009_alter_accountlog_account"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="UnidirectionalFeedback", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"challenge_id", | ||
models.IntegerField(help_text="该反馈对应 Challenge 的 ID"), | ||
), | ||
( | ||
"contents", | ||
models.TextField(help_text="反馈内容,最长 1024", max_length=1024), | ||
), | ||
( | ||
"submit_datetime", | ||
models.DateTimeField(auto_now_add=True, help_text="反馈时间"), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
help_text="反馈用户", | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 4.2.16 on 2024-10-25 06:43 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("frontend", "0010_unidirectionalfeedback"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Feedback", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"content", | ||
models.TextField( | ||
blank=True, help_text="会被放入 <code>div</code> 的 HTML" | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
<script src="{% static 'vue.min.js' %}"></script> | ||
<script src="{% static 'axios.min.js' %}"></script> | ||
<script> | ||
axios.defaults.xsrfCookieName = 'csrftoken'; | ||
axios.defaults.xsrfHeaderName = 'X-CSRFToken'; | ||
</script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div id="app"> | ||
<h1>提交对题目 {{challenge_name}} 的反馈</h1> | ||
<div>{{ feedback.content|safe }}</div> | ||
{% verbatim %} | ||
<div v-if="!too_frequent"> | ||
{% endverbatim %} | ||
<form method="post" class="pure-form pure-form-stacked"> | ||
<fieldset> | ||
{% csrf_token %} | ||
<textarea id="contents" class="pure-input-1" name="contents" rows="20" maxlength="1024" required>{{ contents }}</textarea> | ||
<div class="pure-u-1" style="text-align: right;"> | ||
<button type="submit" class="pure-button pure-button-primary">提交!</button> | ||
</div> | ||
</fieldset> | ||
</form> | ||
{% verbatim %} | ||
</div> | ||
<div v-else> | ||
<p>你对该题目上一次提交反馈在 {{ human_latest_submit() }},需要等待提交后一小时方可再次提交。</p> | ||
</div> | ||
</div> | ||
{% endverbatim %} | ||
{{ too_frequent|json_script:'too-frequent' }} | ||
{{ latest_submit|json_script:'latest-submit' }} | ||
<script> | ||
app = new Vue({ | ||
el: '#app', | ||
data: { | ||
too_frequent: JSON.parse(document.getElementById('too-frequent').textContent), | ||
latest_submit: JSON.parse(document.getElementById('latest-submit').textContent), | ||
}, | ||
methods: { | ||
human_latest_submit() { | ||
if (!this.latest_submit) { | ||
return "" | ||
} | ||
const date = new Date(this.latest_submit) | ||
return date.toLocaleString() | ||
} | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.