=== danilo_ is now known as danilos [12:49] . === nigelb_ is now known as nigelb [12:51] , [12:51] hehe. I was just checking if my nick was correct :) [13:15] daker: mhall119 https://code.launchpad.net/~chrisjohnston/loco-team-portal/team-name-details-page/+merge/86227 === jpds_ is now known as jpds === Ronnie1 is now known as Ronnie [21:51] mhall119: ping [22:07] cjohnston: pong [22:08] mhall119: can you help me with a little ltp trying to optimize a little new code? [22:08] sure [22:08] does the code currently work? [22:09] mhall119: 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:10] "first make it work, then make it right, then make it fast" as the saying goes [22:10] and then make: http://paste.ubuntu.com/775760/ work [22:11] is that an Admin? [22:11] mhall119: forms.py [22:11] Exception Value: Tried team_list in module teams.views. Error was: type object 'Team' has no attribute 'locale_team' [22:11] I 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 value [22:11] but there is a locale_team in the Team model [22:12] show me the model code [22:12] locale_team = models.BooleanField(_("Locale Team"), default=False) [22:13] right, so the Team class doesn't have a locale_team field, only instances of Team get that [22:13] it'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 created [22:14] ok.. so what i can i do to overcome this in forms [22:14] you'll need to override the __init__ method to do that [22:14] I'm not sure on the specifics of adding or removing fields though [22:14] but that's where it would be done [22:15] no idea how to do that of course [22:15] you couldn't just set Meta.exclude at that point, you'll have to manipulate the self.fields array [22:15] is there a better way to do this? [22:16] make 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 other [22:17] I think we already do something similar for giving LC members a different form than team admins [22:17] yes [22:17] so, same basic idea [22:18] make an UpdateLocaleTeam form class [22:18] yup [22:19] then in the team_edit view, add an extra check for if team_object.locale_team [22:23] technically i would need to make a locale team LC view? [22:24] you 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] not really.. as long as they understand that they arent being used so not to expect results by filling stuff in [22:25] that should be fine, I would think [22:27] mhall119: http://paste.ubuntu.com/775779/ [22:28] cjohnston: you have an indentation problem on line 15 of that [22:28] fixed [22:29] also, 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 code [22:29] if is_on_lc: [22:29] do the lc for [22:29] else: [22:29] if locale_team: [22:29] do the locale form [22:30] else: [22:30] do the local form [22:30] make sense? [22:36] http://paste.ubuntu.com/775794/ [22:39] yup, that looks good [22:39] a test case to make sure it's using the correct form would be good too [22:40] mhall119: http://paste.ubuntu.com/775797/ [22:41] should work, yeah [22:41] it doesnt [22:43] oh, that's because 'teams' isn't a template variable [22:43] look at the team_list view function [22:44] add: [22:44] locale_teams = Team.objects.filter(locale_team=True) [22:44] then add that variable to your context dictionary [22:45] then {% for team in locale_teams %} [22:46] yay [22:47] for team_detail.html [22:48] I need to wrap everything that I want in a language team under an if locale_team correct? [22:51] hrm.. for some reason i lost the ability to add a team as a locale team [22:54] mhall119: https://code.launchpad.net/~chrisjohnston/loco-team-portal/locale-teams/+merge/86300 [23:01] mhall119: could you please give the code a test? [23:03] line 183, {% if team.locale_team %} won't work [23:03] wait, I thought you fixed that [23:04] * mhall119 waits for LP to update the diff [23:04] this is taking forever [23:04] i oushed it before i pasted the link [23:36] mhall119: diff updated