Django: How would one organize this big model / manager / design mess? -


Before I get into bad examples, et al: I'm trying to create an application where I don 'To limit options in the current log-in account, all the models have to write the code (I am not using ath, or facilities created for account or login).

That is, I don

  class tickets (models.Model): account = models.ForeignKey (account) client = models.ForeignKey (Client) # of Do not want to do anything: a customer will be owned by an account. Content = model.carfield (max_length = 255) class ticketform (forms.modelform): class meta: model = ticket exited = ('account',) # first sign of bad design? Self __init __ (self, * args, ** kwargs): super (OrderForm, self) .__ init __ (* args, ** kwargs) if self.initial.get ('account'): # is where it is ugly IMHO gets it almost as bad as coding difficult data seems like it does not dry itself either. Field ['customer']. Queryset = Client.objects.filter (account = self.initial.get ('account'))  

My idea is a account with the following custom manager (model.model) < / Code> models, and sub-classes using multi-table inheritance with all your models. Although it is giving me a big brain pain. Do I still need the account foreign key on each model? Can I use a parent model account for example a parent class account?

  Class Ticket Manager (Model Manager): def get_query_set (self): Returns super (ticket manager, self) .get_query_set (). (Account = Account.objects.get (id = 1)) # Obviously I do not want to do this kind of hard code account like this. #I want to do something like this: # Return super (Product Manager, myself) .get_query_set (). Filter (account = self.account) # The current model that is using this manager # (Obviously this is incorrect because you do not have a model # inside the example, but this is where the confusion comes to me. # How will I do this?).  

Please ignore any clear syntax errors. I have typed this whole thing here.

Here is where I got the idea of ​​doing this:

A row level permissions where users / accounts require specific permission to view a specific line (object), in the table, unlike the normal Django AUTH framework which table level permissions < / Em>.

The project that is linked to is one and a third (one of the many projects to implement the row permissions) (my favorite and most active / kept).

Applying row-level permissions will make it easier to hook up the upcoming release of Django 1.2, and

The second related problem is some multi-tenant database which has variation on row permissions. In this scheme you can have many users from the same company, for example, everyone has access to data from that company, but there are no other companies (tenants).

I do not think this is what you are seeing again, but you may be able to use some techniques. Look and the two really have sparse answers, but there are also initial points along with seeing the multi-tenant architecture for the reserve.

In order to give a more specific answer to your question, I think you should either use custom or write the manager and not using the custom manager to bypass the custom manager during the development to verify their questions. Are there.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -