Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Create Cards #1002

Open
JordanPicton opened this issue Jan 22, 2025 · 4 comments
Open

Auto Create Cards #1002

JordanPicton opened this issue Jan 22, 2025 · 4 comments

Comments

@JordanPicton
Copy link

Is this a feature for the backend or frontend?

Backend

What would you like?

I would like to be able to setup a certain task and I assume this would be helpful for others too.

The idea is to have a way for automatic creation of a card basically. For example right now I'm using Plankanban to keep track of daily things that I need to do, not in the same way as Notion but I can give an example below.

Image

Before I get told, I know I'm bad at consistency but this is due to change, anyway the thing I'd be looking for is to have an automated way to take the previous day card and then create a new one that removes the checked boxes and transfer the unchecked ones to the new day keeping the cycle going.

I'm sorry if I didn't explain this in an easy way but I'll summarise below:
Todo list card, new card is created for the next day, using the previous card it removes all the items that have been checked (completed) and copies over the unchecked content to this new card.

Thanks in advance,
~Jordan

Why is this needed?

Not really needed but automation is key and having it would save time from duplicating the card manually, changing the title, dragging it to the top, and then removing the checked boxes.

Other information

No response

@batthias
Copy link

batthias commented Jan 23, 2025

I would kind of assume this (and many other things) could be achieved using something similar to Trello‘s "Automation" features. Having something like that could solve many of those use cases.

Certainly that feature is what still keeps me on Trello instead of just using a self hosted planka instance for everything.

Potentially one could just allow priviledged users to write custom javascript "hooks" per project (instead of having to invent a "user friendly" interface) that get called at certain points.

@hwelch-fle
Copy link

hwelch-fle commented Jan 24, 2025

Edit: I've added this to the examples directory in the plankapy repo if you want to pull it from there

I've written a python API interface for Planka called plankapy that can accomplish this with some pretty simple scripting:

import plankapy as ppy
from plankapy import Planka, PasswordAuth


from datetime import datetime, timedelta, date

def get_project_by_name(planka: Planka, name: str):
    for project in planka.projects:
        if project.name == name:
            return project
    return None

def get_board_by_date(project: ppy.Project, date: date):
    for board in project.boards:
        if board.name == f"{date.year}":
            return board
    return None

def get_card_by_date(list: ppy.List, date: date):
    for card in list.cards:
        if card.name == f"Todo {date.day}/{date.month}/{date.year}":
            return card
    return None

def get_list_by_date(board: ppy.Board, date: date):
    for list in board.lists:
        if list.name == f"{date.strftime('%B')} {date.year}":
            return list
    return None

def main():
    planka = Planka('http://localhost:3001/', auth=PasswordAuth("demo", "demo"))
    
    today = datetime.now().date()
    yesterday = today - timedelta(days=1)
    
    project = get_project_by_name(planka, "Daily Tasks")
    if not project:
        print("Project not found")
        return

    yesterday_board = get_board_by_date(project, yesterday)
    if not yesterday_board:
        print("Yesterday's Board not found")
        return
    
    yesterday_list = get_list_by_date(yesterday_board, yesterday)
    if not yesterday_list:
        print("Yesterday's List not found")
        return
    
    yesterday_card = get_card_by_date(yesterday_list, yesterday)
    if not yesterday_card:
        print("Yesterday's Card not found")
        return
    
    today_board = get_board_by_date(project, today)
    if not today_board:
        today_board = project.create_board(f"{today.year}")
        print(f"Created board for {today.year}")
    
    today_list = get_list_by_date(today_board, today)
    if not today_list:
        today_list = today_board.create_list(f"{today.strftime('%B')} {today.year}")
        print(f"Created List for {today.strftime('%B')} {today.year}")
        
    today_card = get_card_by_date(today_list, today)
    if not today_card:
        print(f"Creating Card for {today.strftime('%d/%m/%Y')}")
        today_card = yesterday_card.duplicate()
        today_card.move(today_list)
        with today_card.editor():
            today_card.name = f"Todo {today.day}/{today.month}/{today.year}"
            today_card.position = 0
            
        for task in today_card.tasks:
            if task.isCompleted:
                print(f"{task.name} completed on {yesterday.strftime('%d/%m/%Y')}, good job!")
                task.delete()
                
    else:
        print("Today's Card already exists!")
    
    print("Created Today's Card")
    
if __name__ == '__main__':
    main()

This script will also handle the creation of new boards and lists as needed if the previous day falls on a different month or year (utilizing the timedelta object in the python standard datetime package)

Initial State:
Image

State after running script:

Image

To use this, just pip install plankapy and run this in your terminal manually or set up a chron job to run it every morning!

@JordanPicton
Copy link
Author

I'll have to give this a look when I'm back home, though how would this work when it comes to running Planka via docker compose?

@hwelch-fle
Copy link

I'll have to give this a look when I'm back home, though how would this work when it comes to running Planka via docker compose?

It's interacting with Planka using a user account and an endpoint. You'd just have to run the script from a computer that can access your planka instance and it'll work.

This is entirely standalone from Planka itself, so you don't need to do any additional setup beyond pip install plankapy, writing your script, then running it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants