コード例 #1
0
ファイル: views.py プロジェクト: eschen42/mastr-ms
def submit(request, *args):
    '''This adds a new user into ldap with no groups
    '''
    detailsDict = getDetailsFromRequest(request)

    email = detailsDict['email']
    user_exists = User.objects.filter(email=email).exists()

    if not user_exists:
        #saveMadasUser will add the user if they do not exist already.
        user_exists = saveMadasUser(AnonymousUser(), email,
                                    detailsDict['details'],
                                    detailsDict['status'],
                                    detailsDict['password'])

        if not user_exists:
            logger.warning("Could not add new user %s" % email)
    else:
        logger.warning("User %s already existed, skipping registration" %
                       email)

    if user_exists:
        sendRegistrationToAdminEmail(request, email,
                                     settings.REGISTRATION_TO_EMAIL)

    return jsonResponse()
コード例 #2
0
ファイル: views.py プロジェクト: eschen42/mastr-ms
def user_save(request, *args):
    '''This is called when an admin user hits save on an individual user record
       from an admin view e.g. Active User Search
       Accessible by Administrators, Node Reps
    '''
    logger.debug('***admin/user_save : enter ***')
    currentuser = getCurrentUser(request)
    parsedform = getDetailsFromRequest(request)
    #look up the user they are editing:
    existingUser = getMadasUser(parsedform['email'])
    existingstatus = existingUser.StatusGroup
    success = saveMadasUser(currentuser, parsedform['email'],
                            parsedform['details'], parsedform['status'],
                            parsedform['password'])
    newstatus = existingUser.StatusGroup

    if newstatus != existingstatus:
        if newstatus == MADAS_USER_GROUP or newstatus == MADAS_REJECTED_GROUP:
            sendApprovedRejectedEmail(request, parsedform['email'], newstatus)
        else:
            sendAccountModificationEmail(request, parsedform['email'])
    #do something based on 'status' (either '' or something new)
    nextview = 'admin:usersearch'
    if newstatus != '':
        if newstatus == MADAS_PENDING_GROUP:
            nextview = 'admin:adminrequests'
        elif newstatus == MADAS_REJECTED_GROUP:
            nextview = 'admin:rejectedUsersearch'
        elif newstatus == MADAS_DELETED_GROUP:
            nextview = 'admin:deletedUsersearch'

    #apply organisational changes
    mail = request.REQUEST['email']
    targetUser, created = User.objects.get_or_create(email=mail)

    try:
        UserOrganisation.objects.filter(user=targetUser).delete()

        try:
            orgid = request.REQUEST['organisation']
            org = Organisation.objects.get(id=orgid)
        except ValueError:
            org = None
        except Organisation.DoesNotExist:
            org = None

        if org:
            uo = UserOrganisation(user=targetUser, organisation=org)
            uo.save()
            logger.debug('added user to org')
    except Exception, e:
        logger.warning(
            'FATAL error adding or removing user from organisation: %s' %
            (str(e)))
コード例 #3
0
ファイル: views.py プロジェクト: AndrewIsaac/mastr-ms
def user_save(request, *args):
    '''This is called when an admin user hits save on an individual user record
       from an admin view e.g. Active User Search
       Accessible by Administrators, Node Reps
    '''
    logger.debug('***admin/user_save : enter ***')
    currentuser = getCurrentUser(request)
    parsedform = getDetailsFromRequest(request)
    #look up the user they are editing:
    existingUser = getMadasUser(parsedform['email'])
    existingstatus = existingUser.StatusGroup
    success = saveMadasUser(currentuser, parsedform['email'], parsedform['details'], parsedform['status'], parsedform['password'])
    newstatus = existingUser.StatusGroup

    if newstatus != existingstatus:
        if newstatus == MADAS_USER_GROUP or newstatus == MADAS_REJECTED_GROUP:
            sendApprovedRejectedEmail(request, parsedform['email'], newstatus)
        else:
            sendAccountModificationEmail(request, parsedform['email'])
    #do something based on 'status' (either '' or something new)
    nextview = 'admin:usersearch'
    if newstatus != '':
        if newstatus == MADAS_PENDING_GROUP:
            nextview = 'admin:adminrequests'
        elif newstatus == MADAS_REJECTED_GROUP:
            nextview = 'admin:rejectedUsersearch'
        elif newstatus == MADAS_DELETED_GROUP:
            nextview = 'admin:deletedUsersearch'

    #apply organisational changes
    mail = request.REQUEST['email']
    targetUser, created = User.objects.get_or_create(email=mail)

    try:
        UserOrganisation.objects.filter(user=targetUser).delete()

        try:
            orgid = request.REQUEST['organisation']
            org = Organisation.objects.get(id=orgid)
        except ValueError:
            org = None
        except Organisation.DoesNotExist:
            org = None

        if org:
            uo = UserOrganisation(user=targetUser, organisation=org)
            uo.save()
            logger.debug('added user to org')
    except Exception, e:
        logger.warning('FATAL error adding or removing user from organisation: %s' % (str(e)))
コード例 #4
0
ファイル: views.py プロジェクト: AndrewIsaac/mastr-ms
def submit(request, *args):
    '''This adds a new user into ldap with no groups
    '''
    detailsDict = getDetailsFromRequest(request)

    email = detailsDict['email']
    user_exists = User.objects.filter(email=email).exists()

    if not user_exists:
        #saveMadasUser will add the user if they do not exist already.
        user_exists = saveMadasUser(AnonymousUser(), email, detailsDict['details'],
                                    detailsDict['status'], detailsDict['password'])

        if not user_exists:
            logger.warning("Could not add new user %s" % email)
    else:
        logger.warning("User %s already existed, skipping registration" % email)

    if user_exists:
        sendRegistrationToAdminEmail(request, email, settings.REGISTRATION_TO_EMAIL)

    return jsonResponse()