Project

General

Profile

Development #1169

Add support of Sites

Added by Mikaël Ates over 7 years ago. Updated about 5 years ago.

Status:
Rejeté
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
23 Dec 2011
Due date:
% Done:

0%

Patch proposed:
No
Planning:
No

Description

Postponed to Authentic2 in SaaS

History

#1 Updated by Anonymous over 7 years ago

The roadmap for this feature can be the following:
  • we need a middleware which put a site reference into each request (request.site), a cache must be constructed linking domain names to site ids.
  • each model should gain a field like this
        site = ForeignKey('sites.Site')
    or like that
        sites = ManyToManyField('sites.Site')
  • each model visible in the admin should use a ModelAdmin which inherit from a new base class, SiteModelAdmin whose queryset() method should look like this:
        def queryset(self, queryset):
            try:
                site_field = self.model._meta.get_field('site') or self.model._meta.get('sites')
                if site_field.name == 'site':
                    q = Q(site=request.site)|Q(site__isnull=True)
                    return queryset.filter(q)
                else:
                    q = Q(sites=request.site)|Q(site__isnull=True)
                    return queryset.filter(q)
            except FieldDoesNotExist:
                return queryset
    
    the goal is to only show object linked to this site
  • we should integrate one of the many applications which allow to put django settings in the db
  • the settings app must be extended to restrict settings by site
  • some caching must be added in order to not touch the db for each access to the settings
  • the AdminSite.has_permission() method should be overloaded to only permit staff users linked to the site using a new table to link users to Site objects.

This should maybe be implemented as a different admin site from the main one which should keep access to all object for superusers.

I'm still looking how to force newly created object to be associated to the current site without doing it manually everywhere.

#2 Updated by Frédéric Péters about 5 years ago

  • Patch proposed set to No
  • Status changed from Nouveau to Rejeté

This has been superseded by multitenant support.

Also available in: Atom PDF