Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,9 @@ def write_report(self, csvfile):
"message",
"entity_id",
"raw_input",
"api_response",
]
)
for cmd in self.commands():
called_api = bool(cmd.response_json)
writer.writerow(
[
self.pk,
Expand All @@ -276,7 +274,6 @@ def write_report(self, csvfile):
cmd.message,
cmd.entity_id(),
cmd.raw.replace("\t", "|"), # tabs are weird in csv
cmd.response_json if called_api else None,
]
)

Expand Down
2 changes: 1 addition & 1 deletion src/web/templates/batches.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2> {% translate 'Last batches' %} {% if username is not None %} {% translate '
</a>
</td>
{% endif %}
<td>{{ batch.name }}</td>
<td>{% if batch.name %}{{ batch.name }}{% else %}-{% endif %}</td>
<td><span class="status status_{{ batch.get_status_display | lower }}">{{ batch.get_status_display | upper }}</td>
<td>{{ batch.modified }}</td>
<td>
Expand Down
20 changes: 16 additions & 4 deletions src/web/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ def test_create_v1_batch_logged_user(self, mocker):
self.assertEqual(list(response.context["page"].object_list), [batch])
self.assertTrue(batch.is_initial)

@requests_mock.Mocker()
def test_create_empty_name(self, mocker):
ApiMocker.is_autoconfirmed(mocker)
user, api_client = self.login_user_and_get_token("user")
response = self.client.post("/batch/new/", data={"type": "v1", "commands": "CREATE"})
self.assertEqual(response.status_code, 302)
response = self.client.get(response.url)
self.assertEqual(response.status_code, 200)
response = self.client.post("/batch/new/preview/allow_start/")
self.assertEqual(response.status_code, 302)
response = self.client.get(response.url)
self.assertTemplateUsed("batch.html")

@requests_mock.Mocker()
def test_create_csv_batch_logged_user(self, mocker):
ApiMocker.is_autoconfirmed(mocker)
Expand Down Expand Up @@ -596,9 +609,8 @@ def test_batch_report(self, mocker):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["Content-Disposition"], f'attachment; filename="batch-{pk}-report.csv"')
result = (
"""b'batch_id,index,operation,status,error,message,entity_id,raw_input,api_response\\r\\n"""
"""1,0,set_statement,Done,,,Q1234,Q1234|P2|Q1,{\\\'id\\\': \\\'Q1234$stuff\\\'}\\r\\n"""
"""1,1,set_label,Done,,,Q11,"Q11|Len|""label""\","""
""""{\\\'id\\\': \\\'Q11\\\', \\\'labels\\\': {\\\'en\\\': \\\'label\\\'}}"\\r\\n\'"""
"""b'batch_id,index,operation,status,error,message,entity_id,raw_input\\r\\n"""
"""1,0,set_statement,Done,,,Q1234,Q1234|P2|Q1\\r\\n"""
"""1,1,set_label,Done,,,Q11,"Q11|Len|""label""\"\\r\\n\'"""
)
self.assertEqual(result, str(response.content).strip())
2 changes: 0 additions & 2 deletions src/web/views/new_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def new_batch(request):
raise ParserException("Command string cannot be empty")

batch_name = batch_name.strip()
if not batch_name:
raise ParserException("Batch name cannot be empty")

if batch_type == "v1":
parser = V1CommandParser()
Expand Down