/srv/irclogs.ubuntu.com/2011/12/19/#ubuntu-website.txt

=== danilo_ is now known as danilos
nigelb_.12:49
=== nigelb_ is now known as nigelb
cjohnston,12:51
nigelbhehe. I was just checking if my nick was correct :)12:51
cjohnstondaker: mhall119 https://code.launchpad.net/~chrisjohnston/loco-team-portal/team-name-details-page/+merge/8622713:15
=== jpds_ is now known as jpds
=== Ronnie1 is now known as Ronnie
cjohnstonmhall119: ping21:51
mhall119cjohnston: pong22:07
cjohnstonmhall119: can you help me with a little ltp trying to optimize a little new code?22:08
mhall119sure22:08
mhall119does the code currently work?22:08
cjohnstonmhall119: not all of it.. nigel wanted to just do it optimized from the start.. trying to figure out if it should be a for or an if or a ......22:09
mhall119"first make it work, then make it right, then make it fast" as the saying goes22:10
cjohnstonand then make: http://paste.ubuntu.com/775760/ work22:10
mhall119is that an Admin?22:11
cjohnstonmhall119: forms.py22:11
cjohnstonException Value: Tried team_list in module teams.views. Error was: type object 'Team' has no attribute 'locale_team'22:11
mhall119I don't think it'll work that way, since Team.locale_team is always going to be the model's default, not the instance's value22:11
cjohnstonbut there is a locale_team in the Team model22:11
mhall119show me the model code22:12
cjohnston    locale_team = models.BooleanField(_("Locale Team"), default=False)22:12
mhall119right, so the Team class doesn't have a locale_team field, only instances of Team get that22:13
mhall119it's part of Django's magic, any class attribute that is a models.*Field gets pulled out and put somewhere else until an instance is created22:13
cjohnstonok.. so what i can i do to overcome this in forms22:14
mhall119you'll need to override the __init__ method to do that22:14
mhall119I'm not sure on the specifics of adding or removing fields though22:14
mhall119but that's where it would be done22:14
cjohnstonno idea how to do that of course22:15
mhall119you couldn't just set Meta.exclude at that point, you'll have to manipulate the self.fields array22:15
cjohnstonis there a better way to do this?22:15
mhall119make two separate Form classes, one for local teams and one for locale teams, and in your view check the .locale_team on the instance, and create one or the other22:16
mhall119I think we already do something similar for giving LC members a different form than team admins22:17
cjohnstonyes22:17
mhall119so, same basic idea22:17
mhall119make an UpdateLocaleTeam form class22:18
cjohnstonyup22:18
mhall119then in the team_edit view, add an extra check for if team_object.locale_team22:19
cjohnstontechnically i would need to make a locale team LC view?22:23
mhall119you could, but LC sees everything right?  would it hurt anything to let them see fields for a locale team that won't be used?22:24
cjohnstonnot really.. as long as they understand that they arent being used so not to expect results by filling stuff in22:24
mhall119that should be fine, I would think22:25
cjohnstonmhall119: http://paste.ubuntu.com/775779/22:27
mhall119cjohnston: you have an indentation problem on line 15 of that22:28
cjohnstonfixed22:28
mhall119also, I'd recommend putting the if team_object.locale_team in the "else" part of the is_on_lc check, it'll be a smaller diff and less duplicate code22:29
mhall119if is_on_lc:22:29
mhall119  do the lc for22:29
mhall119else:22:29
mhall119  if locale_team:22:29
mhall119    do the locale form22:29
mhall119  else:22:30
mhall119    do the local form22:30
mhall119make sense?22:30
cjohnstonhttp://paste.ubuntu.com/775794/22:36
mhall119yup, that looks good22:39
mhall119a test case to make sure it's using the correct form would be good too22:39
cjohnstonmhall119: http://paste.ubuntu.com/775797/22:40
mhall119should work, yeah22:41
cjohnstonit doesnt22:41
mhall119oh, that's because 'teams' isn't a template variable22:43
mhall119look at the team_list view function22:43
mhall119add:22:44
mhall119locale_teams = Team.objects.filter(locale_team=True)22:44
mhall119then add that variable to your context dictionary22:44
mhall119then {% for team in locale_teams %}22:45
cjohnstonyay22:46
cjohnstonfor team_detail.html22:47
cjohnstonI need to wrap everything that I want in a language team under an if locale_team correct?22:48
cjohnstonhrm.. for some reason i lost the ability to add a team as a locale team22:51
cjohnstonmhall119: https://code.launchpad.net/~chrisjohnston/loco-team-portal/locale-teams/+merge/8630022:54
cjohnstonmhall119: could you please give the code a test?23:01
mhall119line 183, {% if team.locale_team %} won't work23:03
mhall119wait, I thought you  fixed that23:03
* mhall119 waits for LP to update the diff23:04
cjohnstonthis is taking forever23:04
cjohnstoni oushed it before i pasted the link23:04
cjohnstonmhall119: diff updated23:36

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!