Пример #1
0
    def handleSubmit(self, action):
        data, errors = self.extractData()
        if errors:
            return

        ids = lambda groupname: frozenset(
            [mm.id for mm in get_users(groupname=groupname)])

        toBeRemoved = ids('Descriptive Cataloguers') & ids(
            'Descriptive Cataloguing Members')
        for username in toBeRemoved:
            api.group.remove_user(groupname='Descriptive Cataloguers',
                                  username=username)

        for username in data['cataloguers']:
            api.group.add_user(groupname='Descriptive Cataloguers',
                               username=username)

        toBeRemoved = ids('Descriptive Cataloguing Reviewers') & ids(
            'Descriptive Cataloguing Members')
        for username in toBeRemoved:
            api.group.remove_user(
                groupname='Descriptive Cataloguing Reviewers',
                username=username)

        for username in data['reviewers']:
            api.group.add_user(groupname='Descriptive Cataloguing Reviewers',
                               username=username)
Пример #2
0
    def getVocabulary(self):
        members = get_users(groupname=self.groupName)
        pairs = [ dict(id=mm.id, fullname=mm.getProperty('fullname')) for mm in members ]
        createTerm = SimpleVocabulary.createTerm
        terms = [createTerm(mm['id'], mm['id'], (u"%s (%s)" % (mm['fullname'],mm['id'])).encode('utf-8')) 
                 for mm in pairs ]
        vocabulary = SimpleVocabulary(terms)

        def search(self,query):
            return [v for v in self if query.lower() in v.value.lower()]

        vocabulary.search = partial(search,vocabulary)
        return vocabulary
Пример #3
0
    def getVocabulary(self):
        members = get_users(groupname=self.groupName)
        pairs = [
            dict(id=mm.id, fullname=mm.getProperty('fullname'))
            for mm in members
        ]
        createTerm = SimpleVocabulary.createTerm
        terms = [
            createTerm(mm['id'], mm['id'],
                       (u"%s (%s)" %
                        (mm['fullname'], mm['id'])).encode('utf-8'))
            for mm in pairs
        ]
        vocabulary = SimpleVocabulary(terms)

        def search(self, query):
            return [v for v in self if query.lower() in v.value.lower()]

        vocabulary.search = partial(search, vocabulary)
        return vocabulary
Пример #4
0
    def handleSubmit(self, action):
        data, errors = self.extractData()
        if errors:
            return
        
        ids = lambda groupname: frozenset([mm.id for mm in get_users(groupname=groupname)])

        toBeRemoved = ids('Descriptive Cataloguers') & ids('Descriptive Cataloguing Members')
        for username in toBeRemoved:
            api.group.remove_user(groupname='Descriptive Cataloguers', username=username)

        for username in data['cataloguers']:
            api.group.add_user(groupname='Descriptive Cataloguers', username=username)

        toBeRemoved = ids('Descriptive Cataloguing Reviewers') & ids('Descriptive Cataloguing Members')
        for username in toBeRemoved:
            api.group.remove_user(groupname='Descriptive Cataloguing Reviewers', username=username)

        for username in data['reviewers']:
            api.group.add_user(groupname='Descriptive Cataloguing Reviewers', username=username)
Пример #5
0
 def actualReviewers(self):
     ids = lambda groupname: set(
         [mm.id for mm in get_users(groupname=groupname)])
     return ids('Descriptive Cataloguing Reviewers') & ids(
         'Descriptive Cataloguing Members')
Пример #6
0
 def actualCataloguers(self):
     ids = lambda groupname: set(
         [mm.id for mm in get_users(groupname=groupname)])
     return ids('Subject Cataloguers') & ids('Subject Cataloguing Members')
Пример #7
0
 def actualReviewers(self):
     ids = lambda groupname: set([mm.id for mm in get_users(groupname=groupname)])
     return ids('Descriptive Cataloguing Reviewers')  & ids('Descriptive Cataloguing Members')
Пример #8
0
 def actualCataloguers(self):
     ids =  lambda groupname: set([mm.id for mm in get_users(groupname=groupname)])
     return ids('Subject Cataloguers') & ids('Subject Cataloguing Members')
from plone.api import content
import geocoder
import chardet
import transaction

name = 'add_missings_member_profiles'

logger = logging.getLogger(name)
hdlr = logging.FileHandler(name + '.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)

logger.info('Collecting all users...')
allusers = user.get_users()

site = app['Plone']
mps_dir = site['directory']
logger.info('Collecting all member profiles...')
mps = [mp for mp in mps_dir.objectValues() if mp.meta_type == 'MemberProfile']

profiles = {}

logger.info('Organizing all member profiles by email...')
for mp in mps:
    email = mp.email
    if email not in profiles:
        profiles[email] = []
    profiles[email].append(mp)