I'm looking to provide super-user access to entities belonging to a specific country.
eg. Swedish SU can only admin Swedish entities, etc...
However, I'm new to django (taking over an old system) and I need a lifeline.
I'd like to be able to specify a relationship table.
I've already added a userprofile and with that I have a new field called super_user_country_link = models.ForeignKey(SuperUserToCountry, blank=True, null=True)
and then underneath a new class
class SuperUserToCountry(models.Model):
user = models.ForeignKey(User)
country = models.ForeignKey(Country)
I plan to run script then to add an entry for each superuser and give them a link to country 0 (ie, no country => total su access). I can then remove these entries as I start to put country-specific entries in So later I can call(using houses as an example):
if user.is_superuser:
if user.get_profile().super_user_county_link.country == 0:
#show house detail...
elsif user.get_profile().super_user_county_link.country == 0
#show house detail...
else
pass
So looking at it, this should mean that I can list multiple countries against a single user, right? Maybe I'm over-thinking it, but does this look correct?
I'm coming from a php background, so I'm just slighty dubious over how correct this is...