Пример #1
0
    def become_member(self, username, invited_by=None, accepted_by=None, password=None):
        """Either a user accepts an invitation or their application is accepted.
        XXX If application is accepted trigger an email with confirmation page to set password
        XXX if invitation is accepted by user then they go straight to set password page
        """
        u = create_user(username, self.email_address)
        if password:
            u.set_password(password)
        u.save()
        p = u.get_profile()
        p.first_name = self.first_name
        p.last_name = self.last_name
        p.email_address = self.email_address
        p.organisation = self.organisation
        p.location = self.location
        if invited_by:
            p.invited_by = invited_by
        if accepted_by:
            p.accepted_by = accepted_by
        h = p.get_host_info()
        h.find_out = self.find_out
        p.save()
        h.save()

        get_all_members_group().add_member(u)

        # do we want to delete the Contact if it becomes a User?
        
        # yes if this is merely a pending user, 
        # no if it's going to grow into a more sophisticated CRM system
        # self.delete()
        
        return u
Пример #2
0
def get_removed_user():
    try:
        removed_user = User.objects.filter(username="******")[0]
    except IndexError:
        from apps.plus_permissions.types.User import create_user

        removed_user = create_user("removed", "*****@*****.**", password="******", permission_prototype="inactive")
        removed_user.save()
    return removed_user
Пример #3
0
def get_removed_user():
    try:
        removed_user = User.objects.filter(username='******')[0]
    except IndexError:
        from apps.plus_permissions.types.User import create_user
        removed_user = create_user('removed',
                                   '*****@*****.**',
                                   password='******',
                                   permission_prototype='inactive')
        removed_user.save()
    return removed_user
Пример #4
0
    def become_member(self,
                      username,
                      invited_by=None,
                      accepted_by=None,
                      password=None):
        """Either a user accepts an invitation or their application is accepted.
        XXX If application is accepted trigger an email with confirmation page to set password
        XXX if invitation is accepted by user then they go straight to set password page
        """
        u = create_user(username, self.email_address)
        if password:
            u.set_password(password)
        p = u.get_profile()
        p.first_name = self.first_name if self.first_name else username
        p.last_name = self.last_name
        p.email_address = self.email_address
        p.organisation = self.organisation
        p.post_or_zip = self.post_or_zip
        p.address = self.address
        p.country = self.country

        if accepted_by:
            p.accepted_by = accepted_by
        h = p.get_host_info()
        h.find_out = self.find_out
        p.save()
        h.save()

        u.is_active = True
        u.cc_messages_to_email = True

        u.save()

        self.user = u
        self.save()
        self.update_applications()
        self.update_invitations()
        for contact in Contact.objects.filter(
                email_address=self.email_address):
            contact.user = u
            contact.update_applications()
            contact.update_invitations()
        other_groups = u.groups.exclude(id=get_all_members_group().id)

        if other_groups.count() == 1:
            u.homehub = other_groups[0]
        else:
            u.homehub = get_all_members_group()
        u.save()

        return u
Пример #5
0
    def become_member(self, username, invited_by=None, accepted_by=None, password=None):
        """Either a user accepts an invitation or their application is accepted.
        XXX If application is accepted trigger an email with confirmation page to set password
        XXX if invitation is accepted by user then they go straight to set password page
        """
        u = create_user(username, self.email_address)
        if password:
            u.set_password(password)
        p = u.get_profile()
        p.first_name = self.first_name if self.first_name else username
        p.last_name = self.last_name
        p.email_address = self.email_address
        p.organisation = self.organisation
        p.post_or_zip = self.post_or_zip
        p.address = self.address
        p.country = self.country

        if accepted_by:
            p.accepted_by = accepted_by
        h = p.get_host_info()
        h.find_out = self.find_out
        p.save()
        h.save()

        u.is_active = True
        u.cc_messages_to_email = True

        u.save()
        
        self.user = u
        self.save()
        self.update_applications()
        self.update_invitations()
        for contact in Contact.objects.filter(email_address=self.email_address):
            contact.user = u
            contact.update_applications()
            contact.update_invitations()
        other_groups = u.groups.exclude(id=get_all_members_group().id) 
 
        if other_groups.count()==1:
            u.homehub = other_groups[0]
        else:
            u.homehub = get_all_members_group()
        u.save()

        return u
Пример #6
0
def dm(username, email, password):
    user = create_user(username, email, password)
    user.set_password(password)
    user.save()
    return user
Пример #7
0
 def make_profile(self, name):
     u = create_user(name, '*****@*****.**' % name)
     return u, u.get_profile()
Пример #8
0
def import_user(u):
    print u['uid'], u['username']
    username = u['username']
    description = u['description']
    roles = u['roles']
    fullname = u['fullname'].strip() 
    biography = u['biography']
    email = u['email']
    portrait = u['portraitfile'].split('/')[-1]
    psn_id = u['uid']
    location = u['location']
    
    if not user_exists(username, email):
        user = create_user(username, email_address=email, password='******')
    else:
        user = User.objects.get(username=username)
    
    user.set_password('password')
    if description : 
        user.description = description
    elif biography :
        user.description = biography

    if not user.homeplace :
        if location :
            p,flag = Location.objects.get_or_create(name=location)
            user.homeplace = p
        else :
            user.homeplace = get_or_create_root_location()
    
    if " " in fullname :
        first, last = fullname.rsplit(' ',1)
    elif "." in fullname :
        first, last = fullname.rsplit('.',1)
    else :
        first = fullname
        last = ''        

    user.first_name = first[:30]
    user.last_name = last[:30]
    user.psn_id = psn_id
    c = 1
    email2 = email
    while (email_exists(email2)) :
        print email2
        email2 = '%s%s'%(c,email)
        c=c+1
    user.email = email2
    user.save()

    f = ImageFile(open('mhpss_export/user_images/%s'%portrait),'rb')
    if f.size == 1357 :
        return # image is plone default ... we don't want it

    path = avatar_file_path(target=user, filename=portrait)
 
    avatar = Avatar(
        target = user.get_ref(),
        primary = True,
        avatar = path,
        )

    avatar.save()
    new_file = avatar.avatar.storage.save(path, f)
    avatar.save()
Пример #9
0
for u in users:    
    print u
    username = u['username']
    description = u['description']
    roles = u['roles']
    fullname = u['fullname'].strip()
    biography = u['biography']
    email = u['email']
    portrait = u['portraitfile'].split('/')[-1]
    psn_id = u['uid']
    location = u['location']
    
    print username, description, fullname, email, biography, roles, portrait, psn_id

    if not user_exists(username, email) :
        user = create_user(username, email_address=email, password='******')
    else :
        try :
            user = User.objects.get(username=username)
        except :
            user = User.objects.get(email_address=email)
    
    user.set_password('password')
    if description : 
        user.description = description
    elif biography :
        user.description = biography

    if not user.homeplace :
        if location :
            p,flag = Location.objects.get_or_create(name=location)
Пример #10
0
def import_user(u):
    print u['uid'], u['username']
    username = u['username']
    description = u['description']
    roles = u['roles']
    fullname = u['fullname'].strip()
    biography = u['biography']
    email = u['email']
    portrait = u['portraitfile'].split('/')[-1]
    psn_id = u['uid']
    location = u['location']

    if not user_exists(username, email):
        user = create_user(username, email_address=email, password='******')
    else:
        user = User.objects.get(username=username)

    user.set_password('password')
    if description:
        user.description = description
    elif biography:
        user.description = biography

    if not user.homeplace:
        if location:
            p, flag = Location.objects.get_or_create(name=location)
            user.homeplace = p
        else:
            user.homeplace = get_or_create_root_location()

    if " " in fullname:
        first, last = fullname.rsplit(' ', 1)
    elif "." in fullname:
        first, last = fullname.rsplit('.', 1)
    else:
        first = fullname
        last = ''

    user.first_name = first[:30]
    user.last_name = last[:30]
    user.psn_id = psn_id
    c = 1
    email2 = email
    while (email_exists(email2)):
        print email2
        email2 = '%s%s' % (c, email)
        c = c + 1
    user.email = email2
    user.save()

    f = ImageFile(open('mhpss_export/user_images/%s' % portrait), 'rb')
    if f.size == 1357:
        return  # image is plone default ... we don't want it

    path = avatar_file_path(target=user, filename=portrait)

    avatar = Avatar(
        target=user.get_ref(),
        primary=True,
        avatar=path,
    )

    avatar.save()
    new_file = avatar.avatar.storage.save(path, f)
    avatar.save()
Пример #11
0
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

        u = create_user('fred', '*****@*****.**')
Пример #12
0
def dm(username, email, password):
    user = create_user(username, email, password)
    user.set_password(password)
    user.save()
    return user
Пример #13
0
 def make_profile(self,name) :
     u = create_user(name, '*****@*****.**'%name)        
     return u, u.get_profile()
Пример #14
0
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

        u = create_user('fred','*****@*****.**')