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

Assign task to multiple people #65

Open
james1293 opened this issue Apr 5, 2019 · 26 comments
Open

Assign task to multiple people #65

james1293 opened this issue Apr 5, 2019 · 26 comments

Comments

@james1293
Copy link
Contributor

Hello all,
I just started using Django todo, and I love the simplicity of it. I recently hacked together a fork (locally, not on GitHub) that allows a task to be assigned to multiple users. It's not perfect yet, but would this be something worth sharing? If so, would it be the sort of thing that would stay as a fork, or could it be incorporated into the main project repo?
(I haven't contributed much on GitHub, so that's why I'm asking for etiquette advice.)
Thanks!

@shacker
Copy link
Owner

shacker commented Apr 6, 2019

Hi James - this is a great idea. It should be as simple as converting the ForeignKey from Task to User to a ManyToMany field, and modifying the UI to allow multi-assignment. It would also have to ensure that emails are sent to all of the right parties.

The general process for contributing to open source on github is this:

  1. Fork the project (you already have)
  2. Make your changes in a branch and push the branch to your fork's repo
  3. Make a pull request for that branch, targeted at this repo
  4. We'll go through the review process - I'll suggest changes, you'll push additional commits
  5. I'll merge it and it will be in!

Thanks.

@shacker shacker changed the title Feature idea - assign task to multiple people Assign task to multiple people Apr 6, 2019
@GoldenBookCover
Copy link

I tried simply converting the ForeignKey from Task to User to a ManyToMany field, it worked almost correctly, except the task_detail view, where i couldn't update the "Assigned to:" column. However it worked fine when creating a new task, or editing the task from the admin panel. Any suggestion?

@james1293
Copy link
Contributor Author

james1293 commented May 11, 2019

Two things -
You have to add form.save_m2m()
For the list display, I did .join(", ")

@shacker
Copy link
Owner

shacker commented May 11, 2019

@MonstreCharmant You would need to replace the Assigned To dropdown with some sort of multiple-choice selection widget. Or did you do that already and I'm misunderstanding the question?

@GoldenBookCover
Copy link

Thank you guys, I just added form.save_m2m(), it worked fine. The code looks like this now, I'm not sure if there is any impact to my data?

# from task_detail.py --> def task_detail() --> # Save task edits
if form.is_valid():
            item = form.save(commit=False)
            item.note = bleach.clean(form.cleaned_data["note"], strip=True)
            item.save()
            form.save_m2m()
            messages.success(request, "The task has been edited.")
            return redirect(
                "todo:list_detail",
                list_id=task.task_list.id,
                list_slug=task.task_list.slug,
            )

@james1293
Copy link
Contributor Author

@MonstreCharmant I added form.save_m2m() in the same place, and it seems to be working. Would you like to share your fork, or do you want me to share mine? Mine is messy (I commented tests that didn't work any more, and I disabled the email notifications) but I could share it as-is anyway...

@shacker
Copy link
Owner

shacker commented Sep 20, 2019

Still hoping that one of you can share your changes back to the mother project here! Pull request please?

@GoldenBookCover
Copy link

Yes, will do that. Working on some jobs now, but I'll share my changes once I got some time.

@f4i5i
Copy link

f4i5i commented Mar 5, 2021

Yes, will do that. Working on some jobs now, but I'll share my changes once I got some time.

can you share your changes

@james1293
Copy link
Contributor Author

I'm sorry that I never did share mine. I'm no longer working at the job where I was working on this, so I don't think that I would be able to access the code easily. If you decide to reimplement it, I wish you the best of luck.

@f4i5i
Copy link

f4i5i commented Mar 5, 2021

can you guide me how you done the task few tips

@james1293
Copy link
Contributor Author

It has been 2 years, so I don't remember a lot of the details. It was something like this:

  • Remove the assigned_to field here.
  • Add a field called assigned_users (or similar). It would look like this: assigned_users = models.ManyToManyField(...).
  • Run a database migration.
  • Search the code for occurrences of assigned_to. Change them appropriately.
    • In particular, when saving a task, you'll need to run form.save_m2m(), as described earlier in this thread.

Feel free to ask follow-up questions. 🙂

@f4i5i
Copy link

f4i5i commented Mar 5, 2021

okay what for selection of users from template

@james1293
Copy link
Contributor Author

I think I started by making sure it worked using the default multi-select interface. Then, once I was sure that that worked, I figured out how to use the pretty widget from the Django admin. There's some advice here (I recommend reading the comments on that answer).

Does that make sense?

@f4i5i
Copy link

f4i5i commented Mar 6, 2021

todo

@f4i5i
Copy link

f4i5i commented Mar 6, 2021

it show something like this and the values not saving in db and i want to make check box to select multiple users

@f4i5i
Copy link

f4i5i commented Mar 6, 2021

one error is this that it show account.customuser.none
task 2

@james1293
Copy link
Contributor Author

Did you add form.save_m2m() as discussed earlier in this thread? That may be the reason why it's not saving.

I've never tried doing the checkboxes.

@f4i5i
Copy link

f4i5i commented Mar 7, 2021

yes i do

@james1293
Copy link
Contributor Author

I don't think there's much more I can do to help right now.

@diogne
Copy link

diogne commented Mar 28, 2021

one error is this that it show account.customuser.none
task 2

I had the same issue of m2m fields being rendered with this "none" thing in a table. Have you tried to add something like this in the template ?
`
{% for customuser in accounts.customuser.all %}
{{ customuser.name }}
{% endfor %}

`

This loop worked fine for me, I hope it will help you !
ps : first comment ever on GitHub - please let me know if I broke any etiquette ^^

@james1293
Copy link
Contributor Author

@diogne thank you, hopefully @f4i5i finds that helpful! 🙂

If you want, you can submit a pull request to accomplish what I never succeeded in finishing 😅

By the way, just so you know about the feature: if you want to put multiple lines of code, a way to do it is to indent them, like this:

these words have four spaces before them
which makes them render as monospace font

@diogne
Copy link

diogne commented Mar 28, 2021

Many thanks for your kind reply and the tips ! I appreciate it !

@bernd-wechner
Copy link
Contributor

This is a great idea and it would rock if someone PRed it.

@palrohitg
Copy link

@bernd-wechner what is the credentials to log

@bernd-wechner
Copy link
Contributor

@bernd-wechner what is the credentials to log

Sorry, but I'm not sure what you're asking. Can you clarify?

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

7 participants