Skip to content

Instantly share code, notes, and snippets.

@chbrown
Created March 15, 2010 18:14
Show Gist options
  • Save chbrown/333116 to your computer and use it in GitHub Desktop.
Save chbrown/333116 to your computer and use it in GitHub Desktop.
10:31:10 AM Christopher Brown: You ever looked at the staff member stuff?
10:31:23 AM mvp-devs: Lee McFadden: no, i haven't.
10:32:59 AM Christopher Brown: Right now it's not very DRY, and I wanted to see what you guys thought of refactoring it.
10:33:09 AM mvp-devs: Lee McFadden: need another set of eyes on the code for something?
10:33:11 AM mvp-devs: Lee McFadden: ah.
10:33:48 AM Christopher Brown: Replace TeamStaff, ContestStaff, VenueStaff (and I think there's one other XStaff) with StaffPosition, which has a many to many on Resource.
10:34:07 AM Christopher Brown: Team, Contest, Venue are all Resources.
10:34:27 AM mvp-devs: Lee McFadden: that sounds pretty logical to me
10:35:04 AM Christopher Brown: Right now TeamStaff has a team_id field, Contest the same, Venue has a many2many on venues.
10:35:33 AM mvp-devs: Lee McFadden: would have to ask CP though for a definitive answer. it's more of a judgement call really. If refactoring is going to be a major benefit in flexibility then I say go for it.
10:36:20 AM Christopher Brown: The one drawback that I can think of is if the Polymorphic inflexibility would prevent searching for, say, all staff at all venues.
10:36:49 AM mvp-devs: Lee McFadden: you could still do that
10:36:55 AM mvp-devs: Lee McFadden: just join to the venues table
10:37:12 AM mvp-devs: Lee McFadden: same with the other types too
10:37:15 AM Christopher Brown: Oh, hmm.
10:37:33 AM mvp-devs: Lee McFadden: i'm pretty sure that'd work, I can't see why it wouldn't
10:38:15 AM Christopher Brown: So that would be like saying, in SA, query(StaffPosition).join((Resource, StaffPosition.resources)).filter(isinstance(Resource, Venue))
10:38:37 AM mvp-devs: Lee McFadden: or make it single table inheritance
10:38:41 AM Christopher Brown: ?
10:38:49 AM mvp-devs: Lee McFadden: and still create different classes
10:39:15 AM mvp-devs: Lee McFadden: wait, that wouldn't work correctly
10:39:22 AM mvp-devs: Lee McFadden: nvm
10:40:09 AM Christopher Brown: My goal is to have one new/edit form that I can finagle Routes onto for basically any resource that allows staff manipulation.
10:40:35 AM Christopher Brown: Right now there's some FormLayout inheritance that keeps it sort of DRY, but still a bit more than optimal.
10:41:34 AM Christopher Brown: And even more importantly, I want one controller for all staff operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment