예제 #1
0
 def add_mom(self, data, meet):
     Validator.validate_mom(meet.close_time, meet.meeting_date,
                            "Minutes of meeting cannot be added")
     meet.description = data['description']
     with transaction.atomic():
         meet.save()
         return Response({'minutes of meeting': meet.description},
                         status=status.HTTP_201_CREATED)
예제 #2
0
def register(
    request,
    format=None,
):
    Validator.validate_superuser(request.user, "Cannot Access")
    data = request.data
    user_detail_service = UserDetailService()
    return user_detail_service.create_user(data)
예제 #3
0
def add_company(
    request,
    format=None,
):
    Validator.validate_superuser(request.user, "Cannot Access")
    data = request.data
    company_detail_service = CompanyDetailsService()
    return company_detail_service.create_company(data)
예제 #4
0
def meet_history(request,format=None):                                   # get history of meeting
    user = request.user
    Validator.validate_company(request.GET.get("comp",None), "Please select a company")
    Validator.validate_contact(request.GET.get("contact",None), "Please select a person to contact")
    meetings = External_Meetings.objects.filter(comp_id=request.GET.get("comp", None), contact_id = request.GET.get("contact", None), user = user)
    return Response({'response' : [{ 'open_time': e.open_time ,
                                    'close_time': e.close_time,
                                    'meeting_date': e.meeting_date,
                                     'description' : e.agenda,
                                     'minutes_of_meeting' : e.description} for e in meetings]}, status=status.HTTP_200_OK)
예제 #5
0
def update_user(
    request,
    format=None,
):
    Validator.validate_superuser(request.user, "Cannot Access")
    data = request.data
    # user = request.user
    user_id = request.GET.get('user_id', None)
    user = user_details.objects.filter(id=user_id)[0]
    # if user.usertype == 'Admin':
    user_detail_service = UserDetailService()
    return user_detail_service.update_user(data, user)
예제 #6
0
 def __validate_input(self, data):
     Validator.validate_string(data.get('title'), "Title cannot be empty!")
     Validator.validate_date(data.get('travel_date'),
                             "Format of date is incorrect",
                             "Date cannot be empty")
     Validator.validate_date(data.get('return_date'),
                             "Format of date is incorrect",
                             "Date cannot be empty")
     Validator.validate_string(data.get('travel_from'),
                               "Location field cannot be empty")
     Validator.validate_string(data.get('travel_to'),
                               "Location field cannot be empty")
예제 #7
0
def get_users(request, format=None,):
    Validator.validate_superuser(request.user , "User not authorized to access")
    user_list = user_details.objects.all()
    return Response([{ "name" : e.name ,
                      "user_id" :e.id,
                      "email": e.email,
                      "mobile": e.mobile ,
                      "address": e.address ,
                      "zone" : e.zone.split(',') if e.zone is not None else e.zone ,
                      "usertype" : e.usertype ,
                       "username" : e.username,
                      "is_active" : e.is_active
    } for e in user_list] , status=status.HTTP_200_OK)
예제 #8
0
def update_company(
    request,
    format=None,
):
    Validator.validate_superuser(request.user, "Cannot Access")
    data = request.data
    # user = request.user
    comp_id = request.GET.get('comp_id', None)
    comp = Company_Details.objects.filter(comp_id=comp_id)[0]
    # user = request.user
    # if user.usertype == 'Admin':
    company_detail_service = CompanyDetailsService()
    return company_detail_service.update_company(data, comp)
예제 #9
0
def active(
    request,
    format=None,
):
    Validator.validate_superuser(request.user, "Cannot Access")
    active = request.GET.get('status', None)
    user_id = request.GET.get('user_id', None)
    user = user_details.objects.filter(id=user_id)[0]
    user.is_active = active
    user.save()
    return Response({
        "user_id": user.id,
        "is_active": user.is_active
    },
                    status=status.HTTP_200_OK)
예제 #10
0
    def __validate_input(self, data, meetings):
        Validator.validate_string(data.get('title'), "Title cannot be empty!")
        Validator.validate_date(data.get('meeting_date'),
                                "Format of date is incorrect",
                                "Date cannot be empty")
        Validator.validate_time(data.get('open_time'),
                                "Time field cannot be empty")
        Validator.validate_time(data.get('close_time'),
                                "Time field cannot be empty")
        Validator.validate_date_today(data.get('meeting_date'),
                                      "Date cannot be from past")
        Validator.validate_meeting_type(data.get('meeting_type'),
                                        "Meeting Type cannot be empty")
        Validator.validate_meet(data['open_time'], data['close_time'],
                                meetings, "Time slot already booked")

        Validator.validate_company(data.get('comp_id'),
                                   "Please select a company")
        Validator.validate_contact(data.get('contact_id'),
                                   "Please select a person to contact")
예제 #11
0
 def validate_updated_input(self, data, meetings, meet_id):
     Validator.validate_string(data.get('title'), "Title cannot be empty!")
     Validator.validate_date(data.get('meeting_date'),
                             "Format of date is incorrect",
                             "Date cannot be empty")
     Validator.validate_date_today(data.get('meeting_date'),
                                   "Date cannot be from past")
     Validator.validate_time(data.get('open_time'),
                             "Time field cannot be empty")
     Validator.validate_time(data.get('close_time'),
                             "Time field cannot be empty")
     Validator.validate_meeting_type(data.get('meeting_type'),
                                     "Meeting Type cannot be empty")
     Validator.validate_updated_meet(meet_id, data['open_time'],
                                     data['close_time'], meetings,
                                     "Time slot already booked")
예제 #12
0
 def __validate_input(self, new_user, data):
     Validator.validate_string(data.get('password'),
                               "Password cannot be empty!")
     Validator.validate_string(data.get('username'),
                               "Username cannot be empty!")
     Validator.validate_string(data.get('usertype'),
                               "Usertype cannot be empty!")
     Validator.validate_zone(data.get('zone'), "Zone cannot be empty!")
     Validator.validate_string(data.get('name'), "name cannot be empty!")
     Validator.validate_string(data.get('email'), "Email cannot be empty!")
     Validator.validate_username(new_user, data.get('username'),
                                 "Duplicate Username!")
     Validator.validate_email(new_user, data.get('email'),
                              "Duplicate Email!")