Open james1293 opened 5 years ago
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.
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?
Two things - You have to add form.save_m2m() For the list display, I did .join(", ")
@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?
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,
)
@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...
Still hoping that one of you can share your changes back to the mother project here! Pull request please?
Yes, will do that. Working on some jobs now, but I'll share my changes once I got some time.
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
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.
can you guide me how you done the task few tips
It has been 2 years, so I don't remember a lot of the details. It was something like this:
assigned_to
field here.assigned_users
(or similar). It would look like this: assigned_users = models.ManyToManyField(...)
.assigned_to
. Change them appropriately.
form.save_m2m()
, as described earlier in this thread.Feel free to ask follow-up questions. :slightly_smiling_face:
okay what for selection of users from template
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?
it show something like this and the values not saving in db and i want to make check box to select multiple users
one error is this that it show account.customuser.none
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.
yes i do
I don't think there's much more I can do to help right now.
one error is this that it show account.customuser.none
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 ?
<td> {% for customuser in accounts.customuser.all %} {{ customuser.name }} {% endfor %} </td>
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 ^^
@diogne thank you, hopefully @f4i5i finds that helpful! :slightly_smiling_face:
If you want, you can submit a pull request to accomplish what I never succeeded in finishing :sweat_smile:
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
Many thanks for your kind reply and the tips ! I appreciate it !
This is a great idea and it would rock if someone PRed it.
@bernd-wechner what is the credentials to log
@bernd-wechner what is the credentials to log
Sorry, but I'm not sure what you're asking. Can you clarify?
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!