Monday, June 25, 2012

Connection Module and Related Views

This week's work went towards finally implementing the connection module with the views I've been envisioning. I started off with two - ConnectionPage and ShowConnectionPage - to be replaced by OrgConnectionPage, UserConnectionPage, and ShowConnectionPage in order to divide up the logic between views and cut down on the (admittedly small) number of conditionals within these pages. You can find the updated model on the main repo, and also right here. Apologies to anybody who might get notifications of commits, I've pretty much been spamming them almost every time I do something substantial or interesting.

First let me start off by saying that I've made some adjustments to the ConnectionModel per Daniel's suggestion and a couple of my own design. The new method for determining the state of the connection relies on four boolean variables: user_mentor, user_org_admin, org_mentor, and org_org_admin. These little switches allow for easily determining the implied state and any promotions. I've also set the parent entity of this model to be the User instance from the org-user relationship and changed it so that the model contains the Profile instance for the User to make it easier to handle promotions and getting certain information in the ShowConnectionPage class.

OrgConnectionPage is fully working, allowing an org admin to initiate a connection between an organization that they are an admin for and a user, granting them the role of either org admin or mentor. Except for the fact that it won't show the ValidationErrors for the role checkboxes...still workin on that one. It will validate (I stole the existing link id cleaning methods for now), create a GSoCConnection entity, and post back onto itself.  The url configuration is pretty simple, just in the format of connect/sponsor/program/organization and you can get to it from the org admin dashboard by clicking on an organization under "My Organizations." I combined the two links for "Invite Mentor" and "Invite Org Admin" into "Start Connection," which I think will suffice until I come up with a more intuitive name. Within the view is a checkbox that allows you to pick either one or both roles to offer. Everybody likes screenshots, so here's a picture:




UserConnectionPage has been giving me a headache. It took me a while but I finally understand the URL configuration system (....I think)  and how it all fits into the big picture along with AccessChecker and RedirectHelper. It's giving me problems at the moment since my connect() method in AccessChecker requires a user keyword argument, and I'm linking it from the Apply class in gsoc/views/org_home which doesn't have the data I need and I'm not seeing a way to put it there. Once I figure that out though (most likely by harassing people on IRC), all I have to do is make a small change in the class's generate() method and it should be working.

The checkAccess() methods on both of these classes should be good to go, but it's likely that someone will point out something I missed and I'm going to feel like a moron. But it's an easy fix, so I'm not stressed out about that at the moment.

The notification module's connectionContext() method should also be very easy to whip together once I get the ShowConnectionPage working, it should just involve creating a template and finishing the rest of the method.

Speaking of ShowConnectionPage, I had this guy working for a little while. Originally I was redirecting to this page after a successful post in OrgConnectionPage and it was showing me everything I wanted to see, but I ended up not liking how it was working and the url configuration started to give me problems so I scrapped most of the work and will take it on this upcoming week. Right after I convince my friend dashboard.py to behave and show all of the GSoCConnection instances properly. Mario if you're reading this I'm probably going to try and track you down with Javascript questions! 

That's all for this week. I've got a couple of questions for the conference call tomorrow (the checkbox errors not showing up and making org_home cooperate for UserConnectionPage, if anyone wants to prepare :P) but if I can figure those out I'll have this fully working by the midterm evaluation.

No comments:

Post a Comment