FreedomCoop / valuenetwork

Fork coming from NRP-Sensorica to use and work for FREEDOM COOP
http://fair.coop
GNU Affero General Public License v3.0
31 stars 12 forks source link

Issues and Q/A about join-project forms (fobi) #140

Closed XaviP closed 8 years ago

XaviP commented 8 years ago

Some issues I've found:

ValueError at /joinaproject/join-to-high-performance-center-for-snail-races/
Cannot assign None: "AgentAssociation.is_associate" does not allow null values.
bhaugen commented 8 years ago

More details on that ValueError from telegram:

Cannot assign None: "AgentAssociation.is_associate" does not allow null values." when reading `/home/ocp/app/valuenetwork/work/views.py in joinaproject_request

The code where this is happening:

 fc_aa = AgentAssociation(
                is_associate=jn_req.agent,
                has_associate=jn_req.project.agent,
                association_type=association_type,
                state="candidate",
                )
            fc_aa.save()

Apparently jn_req.agent is None.

bhaugen commented 8 years ago

This may just be incompleteness: when I go to the link posted in telegram: https://testocp.freedomcoop.eu/work/agent/84/ as a non-admin user-agent who is a coordinator of that project, I see the project.

However, if I just log in as that user-agent in the work app, I can't find it from any of the menus.

[Edit: on /work/agent/84/join-requests/ page I can see a "Your Projects" link, but it gives me a no permissions error.]

bhaugen commented 8 years ago

@bum2 - Questions and comments about the Create OCP Account button on the join-requests page:

bum2 commented 8 years ago

No Bob, the error is in the admin version of FC membership. They need an ocp user and agent in order to start the communication process, so they can be accepted or not after the whole session of feedback using the comments thread. The user+agent is first without even accepting them as members or participants. It's just to start the Q&A about any candidature. So the role of being an OCP participant without being member of nothing now is born. This user-role is 'candidate participant' (only have to see a few options, related the willing project), then can became 'active participant' linked to a project (if accepted by coordinators), and all this with or without FC membership. This 'active participants' can even became 'project coordinators' if they are added as such, but without FCmembership they cannot 'create new projects' (only manage a project in their scope).

bum2 commented 8 years ago

Will be good to change this buttons in FC membership process, so when 'accepted' the same relation change from 'candidate' to 'active'.

bum2 commented 8 years ago

The error is because of the 'candidate' line, it has to be 'potential'... is fixed in my last commit

bhaugen commented 8 years ago

@bum2 I think I understand the "Accepted" action now. So you want them to be created as an OCP participant without being associated with even the project they applied for? What would they be associated with as a participant? It's an association, a relationship in this case between an individual agent and some other (usually context) agent.

(Or am I still not totally getting it...?)

Anyway, to repeat the other questions:

  • Given your ideas about passwords, I assume you have something automatic in mind, not like the form with fields in the Coop Admin app. If so:
    • How should I deal with duplicate ID/Usernames, or Usernames that do not meet the Django rules? 30 characters or fewer. Letters, digits and @/./+/-/_ only.
    • Which of the password options did you want?
    • I can take a first shot at the email message, or you can suggest some wording.

[Edit: I can make some guesses if you don't know either...]

bum2 commented 8 years ago

They need to be created as ocp users+agent and with a 'participant' relation with 'candidate' state in the project (the missing button behavior!). This way they see the project as participators when changed from 'candidate' to 'active' pressing the accept member button (it already works) by a coordinator.

About duplicate nicknames let's fail the button with error message, so the coordinator can change the fields talking with the candidate via comments.

About passwords i think the best is random but short and then send by email to the user. The forgot password feature i think is working good, so don't need to email the pass to coordinators. Anyway is needed to recommend the pass change in the first sessions for new users, so only they know.

bhaugen commented 8 years ago

About duplicate nicknames let's fail the button with error message, so the coordinator can change the fields talking with the candidate via comments.

I'll see what I can do.

bum2 commented 8 years ago

There was an error when join requesting, because i was trying to create the relation of candidate participant when submitting the form, and is totally wrong because the agent nor the user to relate is not yet created. So the same lines to create that relation (work/views.py line 2172) has to be in the button function @bhaugen is doing...

XaviP commented 8 years ago

Commented an error in join request notifications that was sending a lot of emails to admins: https://github.com/FreedomCoop/valuenetwork/commit/2b2adc507dde22f88cbd4a66c3f33b0a3d47aa76 By the way, added @bum2 to the list of admins.

bhaugen commented 8 years ago

That was a new notification, work_join_request, that did not have the required setup.

It needs templates for the email here: https://github.com/FreedomCoop/valuenetwork/tree/master/work/templates/notification and create_notice_type here: https://github.com/FreedomCoop/valuenetwork/blob/master/valuenetwork/valueaccounting/management.py

bum2 commented 8 years ago

Great thanks! i go to do it then...

bhaugen commented 8 years ago

@bum2 I looked for the django_notification doc, and it seems to be gone. It has been superceded by pinax_notifications, which is subtly different, so their doc does not work very well.

The short version is that you need to create a template directory with the name of the notification and put two templates in it, full.txt and short.txt. The short.txt is used for the email subject line.

For a work app notification, the template directory goes here: https://github.com/FreedomCoop/valuenetwork/tree/master/work/templates/notification and here are some examples you can copy-pasta from: https://github.com/FreedomCoop/valuenetwork/tree/master/work/templates/notification/work_membership_request

Then you need to add a create_notice_type here: https://github.com/FreedomCoop/valuenetwork/blob/master/valuenetwork/valueaccounting/management.py

If that does not make sense, ask questions. Both @XaviP and I have done this before.

bum2 commented 8 years ago

Done, commited and testing in testocp...

XaviP commented 8 years ago

I don't find the way to assign a form slug to the project from an admin user (easy with proj manager)

With an admin user which is not project manager of a project, when I go to edit the project, in the modal window, the "Custom form slug" doesn't appear. See as admin user, not project manager, at: https://testocp.freedomcoop.eu/accounting/agent/81/

XaviP commented 8 years ago

Done, commited and testing in testocp.

Uau! I tested but I don't recieve email notification. Now I've run manage.py migrate in testocp to activate the new notification (post-migrate signal), but it doesn't appear in settings/notifications. Any ideas?

bhaugen commented 8 years ago

I don't see the notice type here: https://testocp.freedomcoop.eu/admin/notification/noticetype/

It's possible post_migrate is not doing the setup. I'll try it locally and see what happens.

XaviP commented 8 years ago

Logged in as project manager, I can see the join request of five guys who request join to the project. Trying to visit "Join Requests" tab, I get an error:

AttributeError at /work/agent/81/join-requests/

'NoneType' object has no attribute '_default_manager'

Error in /home/ocp/app/valuenetwork/work/views.py in join_requests

bhaugen commented 8 years ago

It's possible post_migrate is not doing the setup. I'll try it locally and see what happens.

Yeah, post_migrate is not working. Post_syncdb still seems to work so I reverted to that and pushed to master. I think doing a migrate on testocp will now create the new NoticeType.

Post_syncdb is deprecated, though, so sooner or later we should switch to the new AppConfig thingie, as described here: https://pinax-notifications.readthedocs.io/en/latest/usage/#creating-notice-types

XaviP commented 8 years ago

Running migrate in testocp solved it and appears the new subscription in settings. Thanks @bhaugen

bum2 commented 8 years ago

the error @XaviP says at https://github.com/FreedomCoop/valuenetwork/issues/140#issuecomment-245259753 is because the fobi form is lacking the Handler 'DB Store'... just place this in fobi editor and it has to work. By the way, i can't find the 'snails race' form in /fobi ... do you have it there @XaviP ? perhaps is only showing to its author user?

bhaugen commented 8 years ago

The fobi dashboard /fobi/ shows forms by user who created them.

XaviP commented 8 years ago

Added 'DB Store' handler in 'snails race' form. Not possible to edit with admin ( https://github.com/FreedomCoop/valuenetwork/issues/140#issuecomment-245259753 )

XaviP commented 8 years ago

Yes, I think every (admin) user only can see the forms created in /fobi/ by him/herself. At least, I can only se snails race.

El 07/09/16 a les 15:33, bum2 ha escrit:

the error @XaviP https://github.com/XaviP says at #140 (comment) https://github.com/FreedomCoop/valuenetwork/issues/140#issuecomment-245259753 is because the fobi form is lacking the Handler 'DB Store'... just place this in fobi editor and it has to work. By the way, i can't find the 'snails race' form in /fobi ... do you have it there @XaviP https://github.com/XaviP ? perhaps is only showing to its author user?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FreedomCoop/valuenetwork/issues/140#issuecomment-245281559, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcAVV9b109EX2QwrRPdXKojA4olJi3Mks5qnr09gaJpZM4J2Q8f.

bum2 commented 8 years ago

Yes, i see the forms are editable by creator only! we can view them but not edit: https://testocp.freedomcoop.eu/fobi/view/join-to-high-performance-center-for-snail-races/ https://testocp.freedomcoop.eu/fobi/view/faircoin2-cvn-operators/ That's an issue, but first i want to understand the weird error is giving to @XaviP in https://github.com/FreedomCoop/valuenetwork/issues/140#issuecomment-245259753 ... the 'Join Requests' page fails for him, but it works good in the CVN group. Perhaps restart from scratch with the DBstore in place from the first request? perhaps related the checkbox fields?

bhaugen commented 8 years ago

About duplicate nicknames let's fail the button with error message, so the coordinator can change the fields talking with the candidate via comments.

I'll see what I can do.

Error messages here get fairly complicated because it's in a table, so I would need to find the right row for the message, and then return the message to the page somehow from the view.

Alternatively, I could do the whole error thing in javascript.

Much much simpler is what a lot of sites seem to do, which is to continue to append numbers to the requested username until they get a unique one. @bum2 what do you think? The simple method will get this done today. I can't accurately estimate the time for the error messages.

bum2 commented 8 years ago

Ok @bhaugen , we can append numbers to username meanwhile. About the error messages i was imagining a modal notice screen, to don't interfere with the table.

bhaugen commented 8 years ago

About the error messages i was imagining a modal notice screen, to don't interfere with the table.

I have not been using a modal so far for this, but I could do so. That would make the error messages easier.

That would also allow for collective agents without users, and for the project manager to set the passwords. It could be pretty much like the new way for coop admins to create agents+users from membership requests.

That will also take longer, though.

Another question: the JoinRequest form allows for both individual and collective agents. Collective agents can be any of a number of types (projects, cooperatives, etc.) If we allow join requests for collective agents, that pretty much forces a modal form so the project manager can choose, or we need all of those types to be in the choices on the join request form in the first place.

bum2 commented 8 years ago

@bhaugen for the join-request form, now is only individual or collective, because the types of collective allowed can depend on projects choice. I thought that the kind of agent is choosed from the long list when creating the agent, but you are true, if the agent is created by the button we need a fixed type of agent. We can start doing 'group' agent for collective requests, and then later the coordinator or the collective user will choose a better agent type. Individuals is only one agent type, so no problem.

bhaugen commented 8 years ago

I think I am switching to the modal form for this. Might not get done today, but tomorrow latest.

bum2 commented 8 years ago

I didn't mean a modal form, only a modal error message. But one day perhaps we do a modal form just to pick the right agent type or other things. Now we can do only the error message if username conflicts, and that seems easier.

bhaugen commented 8 years ago

To do a modal error message, I will need to do an ajax form submission with an error return from the server, which is okay, but probably the jquery validations are better and not much more work.

bum2 commented 8 years ago

Perhaps is easier to go to a page with success or error of the action? Please do it the way you prefer to have a first working version, then we can improve later.

bhaugen commented 8 years ago

Please do it the way you prefer to have a first working version, then we can improve later.

I'm going with the modal form. Any technical design choice here runs into complications, and I think that will be the most usable in the end, so I might as well do it now.

Holofractographic commented 8 years ago

Hi guys! testing again and.... all th elinks you send through telegram related to forms gives me errors: https://testocp.freedomcoop.eu/joinaproject/faircoin2-cvn-operators/ DoesNotExist at /joinaproject/faircoin2-cvn-operators/ Project matching query does not exist. Request Method: GET Request URL: https://testocp.freedomcoop.eu/joinaproject/faircoin2-cvn-operators/ Django Version: 1.8.14 Exception Type: DoesNotExist Exception Value:
Project matching query does not exist. Exception Location: /home/ocp/app/env/lib/python2.7/site-packages/django/db/models/query.py in get, line 334 Python Executable: /usr/bin/python Python Version: 2.7.9 Python Path:
['/home/ocp/app/valuenetwork', '/home/ocp/app/env/lib/python2.7/site-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/home/ocp/app/valuenetwork/'] Server time: Thu, 8 Sep 2016 09:19:26 +0000

https://testocp.freedomcoop.eu/work/agent/84/ Page not found (404) Request Method: GET Request URL: https://testocp.freedomcoop.eu/work/agent/84/ Raised by: work.views.members_agent No EconomicAgent matches the given query.

https://testocp.freedomcoop.eu/fobi/view/join-to-high-performance-center-for-snail-races/ Page not found (404) Request Method: GET Request URL: https://testocp.freedomcoop.eu/fobi/view/join-to-high-performance-center-for-snail-races/ Raised by: fobi.views.view_form_entry Form entry not found.

:(

bum2 commented 8 years ago

Sorry, we had to erase all the tests and put a older db in testocp. Now i've created again the CVN test project and custom form, and added some of your test users as coordinators: Another Test Agent (Bobtest), Enric, LynnTest, Mario TEST1, Marito, xavi prueba. So, the external form is again at https://testocp.freedomcoop.eu/joinaproject/faircoin2-cvn-operators/ and the project coordination at https://testocp.freedomcoop.eu/work/agent/83/ Please test both the coordinator role and the candidate participant role, so if all works good we can put the updates in production.

bhaugen commented 8 years ago

I'm well on my way to getting the create OCP account button working in what I think is close to the best way. First drop should be in a couple of hours.

bum2 commented 8 years ago

I've commited a js fix for the order of fields in the public form, and the memory of filled fobi fields if any error at submit. The optional 'context_text' decoration field is placed at the top and the captcha at the bottom (you can test it in the cvn form at testocp).

bhaugen commented 8 years ago

I just pushed the first drop of the Create OCP Account button. https://github.com/FreedomCoop/valuenetwork/commit/0ab2151cf94e0f1072f29d44ea6f7a91f55e0a98

@bum2 this is for you to test locally, to see if it does what you want. It has an annoying bug where you need to click Save on the modal form twice. I'll work on fixing that next. It's somewhere in jquery.validate, which is still a big murky tangle to me now and then.

Comments and questions:

bum2 commented 8 years ago

Thanks @bhaugen ! Issues i found testing locally:

The notification emails i can do them, but just tell me how i get the new password to show there...

bhaugen commented 8 years ago
  • The button opens the form for the first item in the list always (at least, is prefilled with the first item data), not the clicked request row user data.

I'll work on that. Got a sqlite database I can test with? Or does testocp have more join requests now?

  • A User is always needed in this step, so the communication can start. Then the password is required and will be good to auto-generate it (without asking) so only seen in the notification email for candidate and coordinators. The creation of sub-agents without user, as sub-projects, comissions or departments of the main project (always context-agents) is intended to be done in the project editor in a future release, but not in the join-requests table.

I'll make the password a required field for now. We can auto-generate passwords if and when we need to do so. In the meantime, anything wrong with just having the project manager enter the password?

  • The 'context-agent' checkbox field should be hidden for coordinators and automatically set depending on the choosed 'agent-type' value.

Ok.

  • The description field is difficult to fill, because is not a requested field: We can decide to have 'description' as a common field for all projects join-requests (intended for gather info about personal skills or collective goals), but the cvn form was not asking this (¿?). For now i think is better to hide the field in this button form, so only can be filled in the agent editor or in the profile at later time.

Ok.

  • The request-faircoin-address is not created in this button function, you are right, but will be good to auto request it when user is 'accepted'.

Just add that line I commented out to the "accepted" view.

The notification emails i can do them, but just tell me how i get the new password to show there...

It's the field called password in work/views/create_account_for_join_request. In plain text at that stage. Gets encrypted in the user.set_password function.

bhaugen commented 8 years ago

@bum2 P.S. if you don't have a sqlite test db with multiple join requests for a project, could you either:

bhaugen commented 8 years ago

tell me how to add join requests, because I don't know.

Never mind, I figured it out. http://127.0.0.1:8000/joinaproject/faircoin2-cvn-operators/

bum2 commented 8 years ago

The public form shows at url /joinaproject/ when public+moderate, and the fobi slug is in the project's field, with the DB-Store handler attached to the fobi form. I've not deployed your commit to testocp yet... just testing locally, but if you want the commits at testocp i can put them now. About the password, yes we can go this way to start, the coordinator creates the initial password manually.

bhaugen commented 8 years ago
  • The button opens the form for the first item in the list always (at least, is prefilled with the first item data), not the clicked request row user data.

Fixed, committed, pushed to master. Also made password required. Have not done this one yet:

  • The 'context-agent' checkbox field should be hidden for coordinators and automatically set depending on the choosed 'agent-type' value.

Will do that one in next update. Also working on the save button bug.

if you want the commits at testocp i can put them now.

No, not ready yet.

bhaugen commented 8 years ago

@bum2 your last update broke my button:

Exception Type: AttributeError
Exception Value:    
'QuerySet' object has no attribute 'append'
Exception Location: /home/bob/.virtualenvs/fc18x/valuenetwork/work/views.py in create_account_for_join_request, line 2429

Error line:

users.append(agent)

Please wait until I get this shit working before changing that method. It is all very fussy. It is not fully working yet. Almost.

I'll comment out your notification code for now, but will also fix the error. You need to turn the queryset into a list in order to append to it.

So like this:

users = list(users)
users.append(agent)
bhaugen commented 8 years ago

Oh, and you also overwrote my correct HttpResponseRedirect URL to an incorrect one

[edit: if you did that on purpose, and want to return to the list instead of the project page to show the new participant, it's ok with me, so I won't change it back.]

bhaugen commented 8 years ago

Wait about half an hour and I'll give it to you.

bhaugen commented 8 years ago

Ok, I pushed my latest to master. I'll leave this all for you for now.

I have not been able to fix the save button bug (where you need to click save twice to get it to save), but I will need to do more jquery validate research to figure that one out. When you are all finished, I'll try that one again. But I think everything else works now.