Esempio n. 1
0
def todo_get():
    logger.debug({
        'action': 'todo_get',
    })
    todo = ToDo()
    data = todo.select_table()
    logger.debug({'action': 'todo_get', 'data': data})
    return jsonify({'data': data}), 200
Esempio n. 2
0
def delete_todo():
    logger.debug({'action': 'todo_delete', 'request': request})
    request_json = request.get_json(force=True)
    id = request_json['id']
    todo = ToDo()
    data = todo.delete_todo(id)
    logger.debug({'action': 'todo_delete', 'data': data})
    return jsonify({'data': data}), 200
Esempio n. 3
0
class TestObject:
    TEST_TRACKER = ToDoTracker()

    TEST_TASK_1 = Task("Task 1")
    TEST_TASK_2 = Task("Task 2")
    TEST_TASK_3 = Task("Task 3")

    TEST_TODO_1 = ToDo("ToDo 1")
    TEST_TODO_2 = ToDo("ToDo 2")
    TEST_TODO_3 = ToDo("ToDo 3")
    TEST_TODO_4 = ToDo("ToDo 4")
    TEST_TODO_5 = ToDo("ToDo 5")
Esempio n. 4
0
    def onMessage(self, msg):
        print msg.body
        if msg["type"] == 'chat' and hasattr(msg, "body"):
            answer = ""
            if msg.body is not None:
                todo = ToDo(str(msg.body))
                answer = todo.execute()
                reply = domish.Element((None, "message"))
                reply["to"] = "*****@*****.**"
                reply["type"] = 'chat'
                reply.addElement("body", content=answer)

            self.send(reply)
Esempio n. 5
0
def add_todo():
    """
    Adds a new To-Do to the list
    """
    task = flask.request.form["task"]
    todos.append(ToDo(task))
    return "success"
Esempio n. 6
0
def todo_send_mail():
    logger.debug({
        'action': 'send-mail',
    })
    todo = ToDo()
    data = todo.select_table()
    config = configparser.ConfigParser()
    config.read('config.ini')
    username = config['EMAIL']['username']
    password = config['EMAIL']['password']
    logger.info({
        'action': 'todo_send_mail',
        'username': username,
        'password': password
    })

    mailer = mail.Mailer(username, password)
    content = data
    mailer.send(recipient_address=username, content=content)
    return jsonify({'data': data}), 200
Esempio n. 7
0
	def load_tasks(self):
		"""
		This function is to lead task list date from storage.
		:return: task object list.
		"""
		data_task = []
		data_file = open(self.storage)
		deliveries_reader = csv.reader(data_file)
		for row in deliveries_reader:
			if row[0] == 'T':
				data_task.append(ToDo(row[1], True if row[2] == 'done' else False))
			elif row[0] == 'D':
				data_task.append(Deadline(row[1], True if row[2] == 'done' else False, row[3]))
			elif row[0] == 'TL':
				data_task.append(TimeLine(row[1], True if row[2] == 'done' else False, row[3], row[4]))
		data_file.close()
		return data_task
Esempio n. 8
0
def todo_register():
    logger.debug({'action': 'todo_register', 'request': request.json})
    todo = ToDo()
    todo.create_table()
    request_json = request.get_json(force=True)
    title = request_json['title']
    rank = int(request_json['rank'])
    deadline = request_json['deadline']
    if title is None:
        return jsonify({'message': 'invalid title'}), 400
    todo.insert_data(title=title, rank=rank, deadline=deadline)
    return jsonify({'message': 'success'}), 200
Esempio n. 9
0
    def get_current_progress(self):
        """
        Obtains progress of current session, ie.
        how many ToDos and Deadlines tasks marked as done.
        Tasks marked pending after being marked done will be
        taken into account.

        Returns
        -------
        Progress for this session.

        """
        status = {'Todo': 0, 'Deadline': 0}
        status['Todo'] = td.progress_check()
        status['Deadline'] = dl.progress_check()
        return ("""Progress for this session:
    | ToDos: {} | Deadlines: {} |""".format(status['Todo'],
                                            status['Deadline']))
Esempio n. 10
0
from todo import ToDo

todo = ToDo()
todo.add('hede')
Esempio n. 11
0
    def execute_command(self, command):
        """
		This function is to execute the command entered
		Do pre processing before call the execution function is need
		:param command: Command entered
		:return: value form execute function
		"""
        if command == 'exit':
            sys.exit()
        elif command.startswith('todo '):
            if self.current_user_level >= 2:
                """Team leader and above is access to add task"""
                description = command.split(' ', 1)[1]
                return self.project.add_task(ToDo(description, False))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('deadline '):
            if self.current_user_level >= 2:
                """Team leader and above is access to add task"""
                command_part = command.split(' ', 1)[1]
                description = self.remove_from_word(command_part, 'by')
                by = self.remove_to_word(command_part, 'by')
                return self.project.add_task(Deadline(description, False, by))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('timeline '):
            if self.current_user_level >= 2:
                """Team leader and above is access to add task"""
                command_part = command.split(' ', 1)[1]
                description = self.remove_from_word(command_part, 'from')
                date = self.remove_to_word(command_part, 'from')
                start_date = self.remove_from_word(date, 'to')
                end_date = self.remove_to_word(date, 'to')
                return self.project.add_task(
                    TimeLine(description, False, start_date, end_date))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('done '):
            if self.current_user_level >= 2:
                """Team leader and above is access to update task"""
                user_index = command.split(' ', 1)[1]
                index = int(user_index) - 1
                if index < 0:
                    raise Exception('Index must be grater then 0')
                else:
                    try:
                        self.project.tasks[index].mark_as_done()
                        return 'Congrats on completing a task ! :-)'
                    except Exception:
                        raise Exception('No item at index ' + str(index + 1))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('pending '):
            if self.current_user_level >= 2:
                """Team leader and above is access to update task"""
                user_index = command.split(' ', 1)[1]
                index = int(user_index) - 1
                if index < 0:
                    raise Exception('Index must be grater than 0')
                else:
                    try:
                        self.project.tasks[index].mark_as_pending()
                        return 'Task mark as pending'
                    except Exception:
                        raise Exception('No item at index' + str(index + 1))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('resource '):
            if self.current_user_level >= 2:
                """Team leader and above is access to add resource"""
                command_part = command.split(' ', 1)[1]
                description = self.remove_from_word(command_part, 'is')
                quantity = self.remove_to_word(command_part, 'is')
                return self.project.add_resources(
                    Resource(description, quantity))
            else:
                raise ValueError('Team leader or above only can add task')

        elif command.startswith('cost of '):
            if self.current_user_level >= 3:
                """Manager and above is access to add cost"""
                command_part = command.split(' ', 2)[2]
                description = self.remove_from_word(command_part, 'is')
                cost = self.remove_to_word(command_part, 'is')
                return self.project.add_cost(Cost(description, cost))
            else:
                raise ValueError('Manager and above only can add cost')

        elif command.startswith('remove '):
            try:
                command_part = command.split(' ', 2)[1]
                command_index = command.split(' ', 2)[2]
                index = int(command_index) - 1
                if command_part == 'task':
                    if self.current_user_level >= 2:
                        """Team leader and above to access to remove task"""
                        return self.project.remove_task(index)
                    else:
                        raise ValueError(
                            'Team leader and above only can remove task')
                elif command_part == 'resource':
                    if self.current_user_level >= 2:
                        """Team Leader and above to access to remove resource"""
                        return self.project.remove_resource(index)
                    else:
                        raise ValueError(
                            'Team leader and above only can remove resource')
                elif command_part == 'cost':
                    if self.current_user_level >= 3:
                        """Manager and above to access to remove cost"""
                        return self.project.remove_cost(index)
                    else:
                        raise ValueError('Manager adn above only remove cost')
            except Exception:
                raise ValueError(
                    'Command format not recognize.\n Command: >>> remove [task/resource/cost] [index]'
                )
        else:
            logging.error('Command not recognized.')
            raise Exception('Command not recognized')
Esempio n. 12
0
def main():
    td = ToDo()
    td.add('build up tolerance to spice')
    td.add('get some new shades')
    td.add('buy sunscreen')
    td.check('build up tolerance to spice')
    td.remove('get some new shades')
    print(td)
    print('completed ' + str(td.completed))
    print('left ' + str(td.not_completed))

    # save our todo
    with open('workfile', 'w') as f:
        td.dump(f)
Esempio n. 13
0
 def __init__(self):
     self.my_tasks = []  # contains tasks (ToDo objects)
     first_task = ToDo(
         "Explore this program",
         "Add and magane new tasks & have fun! Greetings from jq!")
     self.my_tasks.append(first_task)
    def add_todos(self, todo_name, due_date, status):
        """Add todos to the todo collection"""

        user_todo = ToDo(todo_name, due_date, status)
        self.all_todos[todo_name] = user_todo
Esempio n. 15
0
 def createToDoList(self):
     inp = input("""If you already have to-do list for today, 
     this action will rewrite it. Continue? [y/n]\n""")
     if "y" in inp.lower():
         ToDo().create()
Esempio n. 16
0
from todo import ToDo
from arrow import Arrow

todo = ToDo('laundry', Arrow(2019, 2, 25))
due_today = ToDo('shovel snow', Arrow(2019, 2, 19))
overdue = ToDo('dishes', Arrow(2019, 2, 18))
print(todo)
print(due_today)
print(overdue)
Esempio n. 17
0
 def add_task(self, name, description):
     task_to_add = ToDo(name, description)
     self.my_tasks.append(task_to_add)
Esempio n. 18
0
from todo import ToDo, datetime, Arrow
from arrow.arrow import Arrow

print('When is this item due?')

due_year = 2019
due_month = 5
due_day = 25

due_date = Arrow(due_year, due_month, due_day)
todo = ToDo('buy groceries', due_date)
print(todo)

past_due = Arrow(2019, 5, 12)
todo2 = ToDo('dishes', past_due)
print(todo2)

todays_date = Arrow(2019, 5, 13)
due_today = ToDo('mow lawn', todays_date)
print(due_today)
Esempio n. 19
0
def main():
    todo = ToDo("test.json")
    todo.add_item('A pixel is not a pixel is not a pixel', 'programming')
    todo.add_item('The Scheme Programming language', 'programming')
    todo.add_item('Memory in C', 'programming')
    todo.add_item("Haskell's School of Music", 'programming', 'music')
    todo.add_item('Algorithmic Symphonies from one line of code', 'programming', 'music')
    todo.add_item('Modes in Folk Music', 'music')
    todo.add_item('The use of the Meloddic Minor Scale', 'music')

    todo.update_item('The use of the Melodic Minor Scale', 'The use of the Melodic Minor Scale')
    todo.view_list('programming')
    print
    todo.view_list('music')
    print
    todo.view_list('music', 'programming')
Esempio n. 20
0
import flask
import os
import json
from todo import ToDo

app = flask.Flask(__name__, static_url_path="/static")

# List to keep track of all to-dos
todos = [
    ToDo("Make a nicer list of To-Dos"),
    ToDo("Make it so you can add a To-Do"),
    ToDo("Make it so you can complete a To-Do"),
    ToDo("Make it so you can edit the text of a To-Do"),
    ToDo("Make it so you can delete a To-Do")
]


@app.route("/")
def index():
    """
    Just returns the index.html file, which should just load the bundle.js and
    let that do all of the UI work.
    """
    path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__))))
    return flask.send_from_directory(path, 'index.html')


# the "methods" argument limits only HTTP methods of the specified types for
# this endpoint. Since we use the /todos for two different purposes, it's easy
# enough to differentiate the traffic by using just the HTTP method.
@app.route("/todos", methods=["GET"])