コード例 #1
0
ファイル: models.py プロジェクト: mrchrisadams/hubplus
    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
ファイル: default_agents.py プロジェクト: salfield/hubplus
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
ファイル: default_agents.py プロジェクト: GunioRobot/hubplus
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
ファイル: models.py プロジェクト: GunioRobot/hubplus
    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
ファイル: tests.py プロジェクト: GunioRobot/hubplus
 def make_profile(self, name):
     u = create_user(name, '*****@*****.**' % name)
     return u, u.get_profile()
コード例 #8
0
ファイル: users.py プロジェクト: GunioRobot/hubplus
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
ファイル: users.py プロジェクト: mrchrisadams/hubplus
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
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

        u = create_user('fred', '*****@*****.**')
コード例 #12
0
ファイル: users.py プロジェクト: salfield/hubplus
def dm(username, email, password):
    user = create_user(username, email, password)
    user.set_password(password)
    user.save()
    return user
コード例 #13
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
 def make_profile(self,name) :
     u = create_user(name, '*****@*****.**'%name)        
     return u, u.get_profile()
コード例 #14
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

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