Skip to content

Commit

Permalink
Rename choose -> manage
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 19, 2024
1 parent e344cc6 commit f2b8549
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
10 changes: 4 additions & 6 deletions tin/apps/assignments/tests/test_file_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@


@login("teacher")
def test_choose_file_action_view(client, course, file_action) -> None:
def test_manage_file_actions_view(client, course, file_action) -> None:
# make sure the view works
response = client.get(reverse("assignments:choose_file_action", args=[course.id]))
url = reverse("assignments:manage_file_actions", args=[course.id])
response = client.get(url)
assert response.status_code == 200

file_action.courses.clear()
response = client.post(
reverse("assignments:choose_file_action", args=[course.id]),
{"file_action": file_action.id},
)
response = client.post(url, {"file_action": file_action.id})
assert file_action.courses.filter(id=course.id).exists()


Expand Down
6 changes: 3 additions & 3 deletions tin/apps/assignments/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
name="delete_file",
),
path(
"<int:course_id>/files/actions/choose",
views.choose_file_action,
name="choose_file_action",
"<int:course_id>/files/actions/manage",
views.manage_file_actions,
name="manage_file_actions",
),
path(
"<int:course_id>/files/actions/choose/new",
Expand Down
13 changes: 9 additions & 4 deletions tin/apps/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,13 @@ def file_action_view(request, assignment_id, action_id):


@teacher_or_superuser_required
def choose_file_action(request, course_id: int):
"""Choose a file action template."""
def manage_file_actions(request, course_id: int):
"""Add, remove and edit :class:`.FileAction`s for a :class:`.Course`
Args:
request: The request
course_id: The primary key of the :class:`.Course`
"""
course = get_object_or_404(
Course.objects.filter_editable(request.user),
id=course_id,
Expand All @@ -500,12 +505,12 @@ def choose_file_action(request, course_id: int):
course_actions = course.file_actions.all()
return render(
request,
"assignments/choose_file_action.html",
"assignments/manage_file_actions.html",
{
"actions": actions,
"course_actions": course_actions,
"course": course,
"nav_item": "Choose file action",
"nav_item": "Manage file actions",
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script type="text/javascript">
function addFileAction(actionId) {
$.post(
"{% url 'assignments:choose_file_action' course.id %}",
"{% url 'assignments:manage_file_actions' course.id %}",
{
csrfmiddlewaretoken: "{{ csrf_token }}",
file_action: actionId,
Expand Down Expand Up @@ -75,8 +75,7 @@ <h2>Your File Actions</h2>
<div class="card">
<div class="card-content">
<div class="card-topright hidden">
<span onclick="removeFileAction({{ action.id }})">
<i class="fa-solid fa-trash-can red fake-btn" title="Remove from course"></i>
<span onclick="removeFileAction({{ action.id }})" class="fa-solid fa-trash-can red fake-btn" title="Remove from course">
</span>
</div>
<h5 class="card-title">{{ action.name }}</h5>
Expand All @@ -102,8 +101,7 @@ <h2>Choose a File Action</h2>
<div class="card">
<div class="card-content">
<div class="card-topright hidden">
<span onclick="removeFileAction({{ action.id }})">
<i class="fa-solid fa-trash-can red fake-btn" title="Remove from course"></i>
<span onclick="removeFileAction({{ action.id }})" class="fa-solid fa-trash-can red fake-btn" title="Remove from course">
</span>
</div>
<h5 class="card-title">{{ action.name }}</h5>
Expand Down
9 changes: 5 additions & 4 deletions tin/templates/assignments/manage_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ <h4 style="color:red;">{{ file_errors }}</h4>


{% if actions or assignment.last_action_output %}
<h2 style="border-top:1px solid lightgray;padding-top:15px;">File actions</h2>
<h2 style="border-top:1px solid lightgray;padding-top:15px;">
File actions
<a href="{% url 'assignments:manage_file_actions' assignment.course.id %}" class="fa-solid fa-gear"></a>
</h2>

{% for action in actions %}
<a class="left tin-btn" href="{% url 'assignments:file_action' assignment.id action.id %}">{{ action.name }}</a>
{% empty %}
Expand All @@ -63,7 +67,4 @@ <h3>Last action output</h3>
<pre><code class="nohljsln">{{ assignment.last_action_output }}</code></pre>
{% endif %}
{% endif %}

<a class="left tin-btn" href="{% url 'assignments:choose_file_action' assignment.course.id %}">Explore File Actions</a>

{% endblock %}
2 changes: 1 addition & 1 deletion tin/templates/courses/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="left">{{ course.name }}</h2>
{% if request.user.is_superuser %}
<a class="right tin-btn" href="{% url 'admin:courses_course_change' course.id %}">Admin</a>
{% endif %}
<a class="right tin-btn" href="{% url 'assignments:choose_file_action' course.id %}">Manage File Actions</a>
<a class="right tin-btn" href="{% url 'assignments:manage_file_actions' course.id %}">Manage File Actions</a>
<a class="right tin-btn" href="{% url 'courses:edit' course.id %}">Edit</a>
<a class="right tin-btn" href="{% url 'courses:students' course.id %}">Students</a>
{% endif %}
Expand Down

0 comments on commit f2b8549

Please sign in to comment.