예제 #1
0
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    appointment = Utility.get_nested(Appointments, AppointmentSerializer, row['appointment'])

    if len(appointment) > 0:
        appointment['host'] = Utility.get_nested(UserProfile, UserSerializer, appointment['host'])
        appointment['visitor'] = Utility.get_nested(Visitors, VisitorSerializer, appointment['visitor'])
        del appointment['visitor']['image']
        del appointment['host']['image']
        appointment['log'] = row
        row = appointment
    return row
예제 #2
0
    def post(self, request):

        config = ConfigManager().get_config()
        user = None

        username = request.data.get('username', None)
        password = request.data.get('password', None)

        if config.get('authType', 'api') == 'api':
            user = authenticate(username=username, password=password)

        if config.get('authType', 'api') == 'ldap':
            user = LDAPManager().ldap_login(username, password)

        if user is not None:
            if user.is_active:
                token = Token.objects.get(user=user)
                serializer = UserSerializer(user)
                data = serializer.data
                del data['password']
                data['department'] = Utility.get_nested(Department, DepartmentSerializer, data['department'])

                return Response({'user': data, 'token': token.key})
            else:
                return Response({'detail': 'User not active'}, status=status.HTTP_400_BAD_REQUEST)

        return Response({'detail': 'invalid credentials provided'}, status=status.HTTP_401_UNAUTHORIZED)
예제 #3
0
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    row['visitor'] = Utility.get_nested(Visitors, VisitorSerializer, row['visitor'])
    row['host'] = Utility.get_nested(UserProfile, UserSerializer, row['host'])
    row['entrance'] = Utility.get_nested(Entrance, EntranceSerializer, row['entrance'])
    if type(row['visitor']) is dict and len(row['visitor']) > 0:
        row['visitor']['company'] = Utility.get_nested(Company, CompanySerializer, row['visitor']['company'])
        row['visitor']['group'] = Utility.get_nested(VisitorGroup, VisitorGroupSerializer, row['visitor']['group'])

    if type(row['host']) is dict and len(row['host']) > 0:
        row['host']['department'] = Utility.get_nested(Department, DepartmentSerializer, row['host']['department'])

    return row
예제 #4
0
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    visitor = Utility.get_nested(Visitors, VisitorSerializer, row['visitor'])
    host = Utility.get_nested(UserProfile, UserSerializer, row['host'])
    if len(visitor) > 0 and id is not None:
        del visitor['image']
    if len(host) > 0 and id is not None:
            del host['image']
    row['visitor'] = visitor
    row['host'] = host
    row['status'] = Appointments().get_status(row)
    row['entrance'] = Utility.get_nested(Entrance, EntranceSerializer, row['entrance'])
    if type(row['visitor']) is dict and len(row['visitor']) > 0:
        row['visitor']['company'] = Utility.get_nested(Company, CompanySerializer, row['visitor']['company'])
        row['visitor']['group'] = Utility.get_nested(VisitorGroup, VisitorGroupSerializer, row['visitor']['group'])

    if type(row['host']) is dict and len(row['host']) > 0:
        row['host']['department'] = Utility.get_nested(Department, DepartmentSerializer, row['host']['department'])

    return row
예제 #5
0
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    row['company'] = Utility.get_nested(Company, CompanySerializer, row['company'])
    return row
예제 #6
0
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    row['department'] = Utility.get_nested(Department, DepartmentSerializer, row['department'])

    return row