Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit 3db65aa

Browse files
fix bug in update script: if a task was deleted it was saved shortly after, throwing an exception
1 parent 833986f commit 3db65aa

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ the bugboard updates and sort [bugherd](https://www.bugherd.com/)'s tasks and co
99
You will need `python` 3 & `django`.
1010

1111
Some sensitive data are read using `os.environ('KEY')`, you will need to `export` them in order to successfully launch the bugboard:
12+
* `BUGHERD_API` : The access key used to get content from bugherd.com/api_v2/
1213
* `SECRET_KEY` : The django secret key.
1314
* `DB_USER` : PSQL username.
1415
* `DB_PASS` : PSQL password.

bugboard/management/commands/updatebbdb.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import pytz
44
import requests
55
import datetime
6-
from django.core.management.base import BaseCommand
76
from bugboard.models import Tag
87
from bugboard.models import Task
98
from bugboard.models import Member
109
from bugboard.models import Project
1110
from bugboard.models import Comment
11+
from django.core.management.base import BaseCommand
1212

1313

1414
class Command(BaseCommand):
@@ -223,10 +223,6 @@ def update_task_details(self, id_project, t):
223223
task.status = t.get('status', task.status)
224224
task.admin_link = t.get('admin_link', task.admin_link)
225225

226-
# if updated task is closed, then delete it
227-
if task.status == 'closed':
228-
task.delete()
229-
230226
# or create it if it doesn't exist
231227
except Task.DoesNotExist:
232228
task = Task(
@@ -250,7 +246,14 @@ def update_task_details(self, id_project, t):
250246
)
251247
self.task_tag_list.append([t['id'], t['tag_names']])
252248
self.task_assignee_list.append([t['id'], t['assignee_ids']])
253-
task.save()
249+
250+
# if updated task is closed, then delete it
251+
if task.status == 'closed':
252+
task.delete()
253+
else:
254+
# else save it
255+
task.save()
256+
254257
self.display_new_action()
255258

256259
def update_tags(self):

0 commit comments

Comments
 (0)