I set up the ability for departments to have their own news section, that functions the same way the university-wide news does. So, if you work for Gonzaga, and want your department to have its own news section, contact Kim Madsen at 5569, and she can set it up for you and teach you how to enter news articles.
Department News
Posted by: tomlinson | February 26, 2009 Comments Off |Morning Mail, Classmgr/Cashnet
Posted by: tomlinson | February 25, 2009 Comments Off |As any Gonzaga employees, faculty, or students may have noticed, Morning Mail went out late today. This was because we had malformed XML content in the “Today’s Events” rss feed. And by “we”, I mean “I”. It’s fixed, now.
My work on converting Continuing Education’s Class Manager application to Cashnet is complete. I’m just waiting on some final work by the controller’s office to make it live.
HRJobSite work completed
Posted by: tomlinson | February 10, 2009 Comments Off |I’m just awaiting review by HR.
I moved on to CashNet for ClassMgr, but the test item in the store doesn’t seem to be set up to allow purchasing, so the Controller’s office is looking at that.
Spent the rest of the day handling various minor requests, and entering project data into Redman, which is a project management system that integrates with our subversion repository. Very cool.
Currently Working On:
Posted by: tomlinson | January 30, 2009 Comments Off |I’ve got 3 projects underway at the moment:
- Updates to the Online Job Application… uh… application, including the addition of online applications for Faculty positions, for Human Resources
- Converting Continuing Education’s Class Manager application to use Cashnet
- Takedown Manager– a new application in Rails for managing takedown requests from groups like the RIAA and MPAA, for the CIO’s office
I’ve almost completed the updates to the HR app, Takedown Manager is probably halfway complete but on hold for the other two projects to be completed, and I’ll finish the switch to Cashnet once the HR app is done.
Importing Old Blog Posts
Posted by: tomlinson | September 24, 2008 Comments Off |has_and_belongs_to_many: saving when it shouldn’t
Posted by: tomlinson | March 7, 2007 Comments Off |I’ve been working on a Rails Engine for handling admin sections for our custom websites, and I ran into a problem with how HABTM relationships with pre-existing objects save. They save on assignment to the collection, instead of saving when the object itself is saved.
This caused issues because I wanted a nice DRY method for handling updates to almost any object, and I couldn’t include the relationship updates in that method. What I wound up with would save the relationships even if validation failed.
To illustrate, imagine that I have Administrators in a HABTM relationship with Departments, and a generic method for saving them (and anything else that comes along) that looks something like this:
def update_object(object, required_permission_name, multipart = false) if params[:submit] == "Update" if object.save set_crud_notice(object.name, "Update", "successful") redirect_to :action => 'list' else display_view(object, required_permission_name, multipart, 'edit') end else set_crud_notice(object.name, "Update", "cancelled") redirect_to :action => "list" end end
Among other things that I won’t go into, this code takes an object, checks to see if the “Update” button was pressed, and if so, saves the object and kicks the user back to the list page for the current controller. If another button was pressed, it also kicks the user back to the list page, but without saving anything. If the save fails, it displays the edit page again.
In the Administrator and Department controllers, I have simple methods like so:
def update @administrator = Administrator.find(params[:id] ) @administrator.attributes = params[:administrator] if params[:department_ids] @administrator.departments = Department.find(params[:department_ids] ) elsif @administrator.departments.empty? @administrator.departments = [] end update_object(@administrator, "UsersAdministratorsEdit") end
This method finds the administrator, assigns its attributes, sets up the relationships, and then saves the object via the update object method.
This all looks okay, except that no matter the outcome of the update_object method, the relationships get saved. I know there are many ways solve this issue, but none of the ones I found were DRY enough. That is, until I remembered something I saw Dave Thomas show off at the Rails Edge Conference, something I thought was so obnoxious that there was no possible good reason to use it outside of sheer geek self-indulgence: passing a block to a method.
Passing a block to the update_object method allowed me to save the relationships after a successful object save, and before the redirect to the list upon success. It also allowed me to use the same method for objects with one HABTM relationship, or many.
Using the examples I’ve got here, this is what I wound up with:
def update_object(object, required_permission_name, multipart = false, &block) # if no block is passed, make it do nothing block ||= Proc.new {|obj| nil} if params[:submit] == "Update" if object.save # execute block, this is usually used for dealing with HABTM relationships block.call(object) set_crud_notice(object.name, "Update", "successful") redirect_to :action => 'list' else display_view(object, required_permission_name, multipart, 'edit') end else set_crud_notice(object.name, "Update", "cancelled") redirect_to :action => "list" end end
and
def update @administrator = Administrator.find(params[:id] ) @administrator.attributes = params[:administrator] if params[:department_ids] @selected_departments = Department.find(params[:department_ids] ) else @selected_departments = [] end update_object(@administrator, "UsersAdministratorsEdit") do |obj| obj.departments = @selected_departments end end
Now, all I have to do is move the assignment of relationships to be within the block, and store unsaved relationships in a separate array, instead of one of the other, less DRY options.
P.S. Because it annoys me when people use acronyms without explaining them:
DRY = Don’t Repeat Yourself
HABTM = has_and_belongs_to_many
Done
Posted by: tomlinson | February 8, 2006 Comments Off |I finished the Walking Works site. Hooray.
Too bad nobody reads this.
Walking Works Logging Site
Posted by: tomlinson | January 26, 2006 Comments Off |I’m currently working on a site for the Wellness Committee that will allow people to enter their Walking Works data, create teams, and view their histories.
I just felt like telling someone what I was working on. Too bad nobody reads this.
Done.
Posted by: tomlinson | June 23, 2005 Comments Off |About two hours after that last post, I got it to work, much to my surprise.
Blackboard *dramatic pause*
Posted by: tomlinson | June 22, 2005 Comments Off |I’ve been working on implementing custom authentication for Blackboard for about a week and a half. What I want to do is very simple in concept, to the point that if I had access to Blackboard’s java source code for their LDAPAuthModule, I’d only have to change two lines of code.
Unfortunately, they also won’t give me the full API to their authentication classes, and their documentation is very poor. I could go on, but I suppose working on it might actually be more productive.
