Changeset 476 in main


Ignore:
Timestamp:
11/14/11 16:36:16 (8 years ago)
Author:
pcosquer
Message:

search: users & groups: update the index only if the object have been modified/created by a controller
This should reduce the number of calls to update_index

Location:
trunk/openPLM/plmapp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers/group.py

    r440 r476  
    3535import openPLM.plmapp.models as models 
    3636from openPLM.plmapp.mail import send_mail 
     37from openPLM.plmapp.tasks import update_index 
    3738from openPLM.plmapp.exceptions import PermissionError 
    3839from openPLM.plmapp.controllers.base import Controller, permission_required 
     
    8788        user.groups.add(obj) 
    8889        res._save_histo("Create", details) 
     90        update_index.delay("plmapp", "groupinfo", obj.pk) 
    8991        return res 
    9092 
     
    206208        invitation.save() 
    207209        # TODO mail 
    208  
     210     
     211    def save(self, with_history=True): 
     212        u""" 
     213        Saves :attr:`object` and records its history in the database. 
     214        If *with_history* is False, the history is not recorded. 
     215        """ 
     216        super(GroupController, self).save(with_history) 
     217        update_index.delay("plmapp", "groupinfo", self.object.pk) 
  • trunk/openPLM/plmapp/controllers/user.py

    r440 r476  
    3737import openPLM.plmapp.models as models 
    3838from openPLM.plmapp.mail import send_mail 
     39from openPLM.plmapp.tasks import update_index 
    3940from openPLM.plmapp.utils import generate_password 
    4041from openPLM.plmapp.exceptions import PermissionError 
     
    153154        self.object.get_profile().save() 
    154155        super(UserController, self).save(with_history) 
     156        update_index.delay("auth", "user", self.object.pk) 
    155157 
    156158    def has_permission(self, role): 
     
    250252                "password" : password, 
    251253               } 
     254        update_index.delay("auth", "user", new_user.pk) 
    252255        self._send_mail(send_mail, "New account on openPLM", [new_user], 
    253256                ctx, "mails/new_account")  
  • trunk/openPLM/plmapp/search_indexes.py

    r471 r476  
    6060    pass 
    6161 
    62 class UserIndex(QueuedModelSearchIndex): 
     62class UserIndex(ModelSearchIndex): 
    6363    class Meta: 
    6464        pass 
     
    7070site.register(models.User, UserIndex) 
    7171 
     72class GroupIndex(ModelSearchIndex): 
     73    class Meta: 
     74        pass 
     75     
     76    rendered = CharField(use_template=True, indexed=False) 
     77    rendered_add = CharField(use_template=True, indexed=False) 
     78 
     79set_template_name(GroupIndex) 
     80site.register(models.GroupInfo, GroupIndex) 
     81 
     82 
    7283 
    7384for key, model in models.get_all_plmobjects().iteritems(): 
     85    if model == models.GroupInfo: 
     86        continue 
    7487    class ModelIndex(QueuedModelSearchIndex): 
    7588        model = model 
Note: See TracChangeset for help on using the changeset viewer.