Hi, 

 

Well if i understand you correctly it doesnt sound so hard. 

Every user can have one or more businesses and every artikel can have on
business. 

So you just query for all articles where the business matches one of the
businesses the user belongs to. 

 

Hope that helps

 

Patrick

 

Von: [email protected]
[mailto:[email protected]] Im Auftrag von Mario Gudelj
Gesendet: Donnerstag, 17. November 2011 09:14
An: [email protected]
Betreff: controlling user access

 

Hi Djangoers,

 

I have a problem on my hands I'm not sure how to approach and would
appreciate your guidance.

 

I'm building a site that will host articles for separate businesses and
each business will have a user who needs to log in and administer
article that only belong to a particular business.

 

So, I have the following model:

 

class Business(models.Model):

    id = models.AutoField(primary_key=True)

    name = models.CharField("Business Name", max_length=50, blank=False)

    slug = models.SlugField("Slug", max_length=255, unique=True,
blank=False)

    ....

 

class StaffProfile(models.Model):

    user = models.ForeignKey(User, unique=True)

    

    id = models.AutoField(primary_key=True)

    ....

    business = models.ManyToManyField(Business)

 

 

class Article(models.Model):

    id = models.AutoField(primary_key=True)

    business = models.ForeignKey(Business, null=False)

    ....

 

So, every business will have a separate subdomain and will have a unique
slug. 

 

Users can belong to one or more businesses and my StaffProfile extends
the Django's user class.

 

What I don't know is how to authenticate a user into a particular
business, so that this user only has access to the business they are
logged into.

 

What I want them to do is to choose which business they want to log into
on the login and once they enter the username, password and select the
business I want them to be able to access articles that only belong to
that business and none of the articles that belong to those other
businesses.

 

Any help or suggestions will be highly appreciated. Thanks guys!

 

Mario 

 

 

-- 
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:[email protected]
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to