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