Skip to content

Commit

Permalink
Set project name to project slug
Browse files Browse the repository at this point in the history
  • Loading branch information
kostajh committed Apr 11, 2013
1 parent 306b623 commit aac7afb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bugwarrior/services/activecollab3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import json
import datetime
import re

api_count = 0
task_count = 0
Expand Down Expand Up @@ -40,6 +41,14 @@ def format_date(self, date):
timestamp = int(time.mktime(d.timetuple()))
return timestamp

def get_project_slug(self, project_name):
# Take a project name like "Client: Example Project" and return a
# string in project slug format: "client-example-project"
project_name = project_name.lower()
project_name = re.sub('[\s+]', '-', project_name)
project_name = re.sub('[:]', '', project_name)
return project_name

# Return a priority of L, M, or H based on AC's priority index of -2 to 2
def format_priority(self, priority):
priority = str(priority)
Expand Down Expand Up @@ -69,8 +78,8 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
assigned_task['permalink'] = task[u'permalink']
assigned_task['task_id'] = task[u'task_id']
assigned_task['id'] = task[u'id']
assigned_task['project_id'] = project_id
assigned_task['project'] = project_name
assigned_task['project_id'] = task[u'project_id']
assigned_task['project'] = self.get_project_slug(project_name)
assigned_task['description'] = task[u'name']
assigned_task['type'] = "task"
assigned_task['created_on'] = task[u'created_on'][u'mysql']
Expand Down Expand Up @@ -106,7 +115,8 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
if subtask[u'parent_id'] == t[u'id']:
assigned_task['permalink'] = t[u'permalink']
assigned_task['task_id'] = subtask[u'id']
assigned_task['project'] = project_name
# Get the project slug
assigned_task['project'] = self.get_project_slug(project_name)
assigned_task['project_id'] = project_id
assigned_task['description'] = subtask['body']
assigned_task['type'] = 'subtask'
Expand Down

0 comments on commit aac7afb

Please sign in to comment.