Example #1
0
def auth_view(request):
    
    username = request.POST['username']
    password = request.POST['pwd']
    #type_label = request.POST['sel1']
    
    try:
        user = Employee.objects.get(username=username,password=password)
        
        
        #str(AllUser.getSpec(user))
        if user is not None:
            try:
                doctor_user=Doctor.objects.get(username=username)
                request.session['for_id']=str(doctor_user.id)
            except:
                request.session['for_id']=""
            request.session['userid']=str(user)
            request.session['usertype']=Employee.getType(user)
            request.session['userspec']=Employee.getSpec(user)
            if 'DO' in request.session['usertype']:
                return redirect('doctors:appointments')
            elif 'RE' in request.session['usertype']:
                return redirect('records:frontdesk')
            elif 'NU' in request.session['usertype']:
                return redirect('nurses:frontdesk')
            elif 'LA' in request.session['usertype']:
                return redirect('lab:view-patient-tests')
            elif 'PH' in request.session['usertype']:
                return redirect('pharmacy:view-patient-prescriptions')
        #return HttpResponseRedirect('')
    except Employee.DoesNotExist:
       
        return render(request, 'login/login.html', {"error":'Invalid Input'})
Example #2
0
    def create(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data)

        if serializer.is_valid():
            commerce = serializer.save()

            profileId = request.data['profileId']
            profile = Profile.objects.get(id=profileId)
            profile.commerceId = commerce
            profile.save()

            role = Role.objects.get(id='OWNER')

            employee = Employee(profileId=profile,
                                commerceId=commerce,
                                roleId=role,
                                inviteDate=datetime.datetime.now(),
                                startDate=datetime.datetime.now())
            employee.save()

            return JsonResponse(data={
                'commerceId': commerce.id,
                'employeeId': employee.id
            },
                                status=201)

        return JsonResponse(status=400)
Example #3
0
def regConEmployee(request):
    ID = request.POST['ID']
    PW = request.POST['PW1']
    re_PW = request.POST['PW2']
    name = request.POST['name']
    gender = request.POST['gender[]']
    work_type = request.POST['work_type[]']
    birthdate = request.POST['birthdate']
    address = request.POST['address']
    phone_number = request.POST['phone_number']
    res_data = {}

    if not (ID and PW and re_PW and name and gender and work_type and address
            and phone_number):
        res_data['error'] = "모든 값을 입력해야 합니다."
        return render(request, 'employees/registerEmployee.html', res_data)
    if PW != re_PW:
        res_data['error'] = '비밀번호가 다릅니다.'
        return render(request, 'employees/registerEmployee.html', res_data)
    else:
        qs = Employee(e_ID=ID,
                      e_PW=make_password(PW),
                      e_name=name,
                      e_gender=gender,
                      e_work_type=work_type,
                      e_birthdate=birthdate,
                      e_address=address,
                      e_phone_number=phone_number)
        qs.save()
        return HttpResponseRedirect(reverse('employees:login'))
Example #4
0
def create_post(request):

    if request.method == 'POST':
        employee_name = request.POST.get('name')
        employee_title = request.POST.get('job_title')
        employee_experience = request.POST.get('years_experience')
        employee_department = request.POST.get('department')
        # employee_image = request.FILES.get('image')

        response_data = {}

        employee = Employee(name=employee_name, job_title=employee_title, years_experience=employee_experience, department=employee_department)
        employee.save()

        response_data['result'] = 'Added employee successfully!'
        response_data['employeepk'] = employee.pk
        response_data['name'] = employee.name
        response_data['job_title'] = employee.job_title
        response_data['years_experience'] = employee.years_experience
        response_data['department'] = employee.department
        # response_data['image'] = employee.image



        return      HttpResponse(
               json.dumps(response_data),
                content_type="application/json"
            )

    else:
        return HttpResponse(
            json.dumps({"nothing to see": "this isn't happening"}),
            content_type="application/json"
        )
Example #5
0
def add_employee():
    name = request.json['name']
    department = request.json['department']

    hired_date = datetime.utcnow().strftime("%Y-%m-%d")
    new = Employee(name=name, department=department, hired_date=hired_date)
    new.save()
    return json.dumps({'success': True})
Example #6
0
def make_employee(first_name, last_name, phone, birthday_date, department,
                  job_position):
    user = make_user(first_name, last_name)
    employee = Employee(user=user, status=20, phone=phone,
                        birthday_date=birthday_date, department=department,
                        job_position=job_position)
    employee.save()
    return employee
Example #7
0
def register_view(request, *args, **kwargs):
    form = SignUpForm(request.POST or None)

    if form.is_valid():
        user = form.save(commit=True)
        user.refresh_from_db()
        user.set_password(form.cleaned_data.get("password1"))

        user.save()

        last_name = form.cleaned_data.get("last_name")
        first_name = form.cleaned_data.get("first_name")
        middle_name = form.cleaned_data.get("middle_name")
        sex = form.cleaned_data.get("sex")
        birthday = form.cleaned_data.get("birthday")
        pass_series = form.cleaned_data.get("pass_series")
        pass_number = form.cleaned_data.get("pass_number")
        inn = form.cleaned_data.get("inn")
        email = form.cleaned_data.get("email")
        address = form.cleaned_data.get("address")
        phone = form.cleaned_data.get("phone")
        
        role = form.cleaned_data.get("role")

        employee = Employee(
            last_name=last_name,
            first_name=first_name,
            middle_name=middle_name,
            sex=sex,
            birthday=birthday,
            pass_series=pass_series,
            pass_number=pass_number,
            inn=inn,
            email=email,
            address=address,
            phone=phone,
            role=role,
            user=user
        )

        employee.save()

        login(request, user)

        return redirect("/")

    context = {
        "form": form,
        "btn_label": "Зарегистрироваться",
        "title": "Регистрация"
    }

    return render(request, "auth/auth.html", context)
Example #8
0
def create_employee_instance(request):
    # Fetching data from the add new employee form
    first_name = request.POST['first_name']
    last_name = request.POST['last_name']
    grade = request.POST['grade']
    basic_salary = request.POST['basic_salary']
    bonus = request.POST['bonus']
    local_service_tax = request.POST['local_service_tax']
    lunch_allowance = request.POST['lunch_allowance']
    gender = request.POST['gender']
    marital_status = request.POST['marital_status']
    start_date = request.POST['start_date']
    nationality = request.POST['nationality']
    nssf_no = request.POST['nssf_no']
    ura_tin = request.POST['ura_tin']
    national_id = request.POST['national_id']
    telephone = request.POST['telephone']
    residence_address = request.POST['residence_address']
    dob = request.POST['dob']
    renumeration_currency_id = request.POST['renumeration_currency']
    title = request.POST['title']
    work_station = request.POST['work_station']
    currency = Currency.objects.get(pk=renumeration_currency_id)
    # try:
    # Creating instance of Employee
    employee = Employee(first_name=first_name,
                        last_name=last_name,
                        basic_salary=basic_salary,
                        grade=grade,
                        gender=gender,
                        marital_status=marital_status,
                        start_date=start_date,
                        nationality=nationality,
                        nssf_no=nssf_no,
                        ura_tin=ura_tin,
                        national_id=national_id,
                        telephone_no=telephone,
                        residence_address=residence_address,
                        dob=dob,
                        currency=currency,
                        title=title,
                        work_station=work_station,
                        lunch_allowance=lunch_allowance,
                        bonus=bonus,
                        local_service_tax=local_service_tax)
    # Saving the employee instance
    employee.save()

    add_leave_record(employee, start_date)

    return employee
Example #9
0
def add_employee(request):
	employee_name = request.GET.get('name', '')
	employee_email = request.GET.get('email','')
	employee_departament = request.GET.get('departament','')
	#salvando no banco de dados
	Employee(name=employee_name, email=employee_email, departament=employee_departament).save()
	return redirect('employees')
Example #10
0
    def post(self, request):
        """
        Will only respond to POST requests containing
        an email address to search employees.

        We're checking for q because the users can to this
        endpoint because they've searched for an email address
        stored in q. If no email was sent - go back to dashboard.

        This logic should be improved to provide a validation error
        message to the user.
        """
        if 'q' not in request.POST.keys():
            return Http404()
        try:
            # attempt to create a new user by authenticating against the API
            employee = Employee(token=self.token)
            employees = employee.objects.filter(
                email__contains=request.POST.get('q')
            )
            return render(
                request, self.template,
                {
                    'employees': employees,
                    'user_name': self.user_name,
                    'page_title': 'Employee Search Results'
                }
            )
        except Exception as ex:
            return HttpResponseRedirect('/dashboard')

        return HttpResponseRedirect('/dashboard')
Example #11
0
def validate_code_employee(request):
    actionMsg = ''
    finded = 0
    context = {}
    if request.method == 'POST':
        code = request.POST.get('code', None)
        employee = Employee()
        try:
            employee = Employee.objects.get(code=code)

            locale.setlocale(locale.LC_ALL, 'Spanish_Spain.1252')
            now = datetime.datetime.now()
            dayName = now.strftime("%A")
            dayNumber = now.day

            assistance = Assistance.objects.create(date=now,
                                                   dayNumber=dayNumber,
                                                   day=dayName,
                                                   attended=True,
                                                   checkInTime=now,
                                                   registrationDate=now,
                                                   modifitacionDate=now,
                                                   employee=employee)

            actionMsg = 'Bienvenido ' + employee.userprofile.name
            finded = 1
        except Employee.DoesNotExist:
            actionMsg = 'Usuario no encontrado'
            finded = 2

        print(actionMsg)
        print(finded)
        request.session['finded'] = finded
        request.session['actionMsg'] = actionMsg
    return render(request, "assistance/assistance-taking.html", context)
Example #12
0
def create_test_employees(professions):
    employees = [
        Employee(name='test',
                 last_name='test',
                 email='*****@*****.**',
                 profession=professions[0]),
        Employee(name='test',
                 last_name='test',
                 email='*****@*****.**',
                 profession=professions[1])
    ]

    for employee in employees:
        employee.save()

    return employees
Example #13
0
def regConEmployee(request):
    ID = request.POST['ID']
    PW = request.POST['PW']
    name = request.POST['name']
    gender = request.POST['gender']
    work_type = request.POST['work_type']
    birthdate = request.POST['birthdate']
    address = request.POST['address']
    phone_number = request.POST['phone_number']

    qs = Employee(e_ID=ID,
                  e_PW=PW,
                  e_name=name,
                  e_gender=gender,
                  e_work_type=work_type,
                  e_birthdate=birthdate,
                  e_address=address,
                  e_phone_number=phone_number)
    qs.save()

    return HttpResponseRedirect(reverse('employees:emAll'))
Example #14
0
    def update(self, instance: employee_models.Employee,
               validated_data: dict) -> employee_models.Employee:
        """
        Update an employee and encode updated password if present

        Args:
            instance: existing employee instance
            validated_data: validated serializer data

        Returns:
            the updated employee instance
        """
        password = validated_data.pop('password', None)
        if password is not None:
            instance.set_password(password)

        for field, value in validated_data.items():
            setattr(instance, field, value)

        instance.save()
        return instance
Example #15
0
    def create(self, request):
        name = request.data['name']
        address = request.data['address']

        if Company.objects.filter(name=name).exists():
            return Response(data='Companay with the same name already exists.',
                            status=status.HTTP_400_BAD_REQUEST)

        # Schema name is same as the company name
        schema_name = name
        domain_url = name + settings.DOMAIN_NAME

        try:
            company = Company(name=name,
                              schema_name=schema_name,
                              domain_url=domain_url,
                              address=address)
            # The option below is meant to clean up corresponding schema when a company is deleted.
            # But this does not seem to work.
            company.auto_drop_schema = True
            company.save()
        except Exception as e:
            return Response(
                data='Unable to create Companay with the given input.',
                status=status.HTTP_400_BAD_REQUEST)

        # Create company admin user in the tenant/company schema
        with schema_context(company.schema_name):
            company_admin_name = company.schema_name + '_admin'
            user = User.objects.create_user(username=company_admin_name,
                                            password='******')
            employee = Employee(name=company_admin_name,
                                is_company_admin=True,
                                user=user)
            employee.save()

        return Response(data='Company successfully created.',
                        status=status.HTTP_201_CREATED)
Example #16
0
    def get_context_data(self, **kwargs):
        """
        Query the rest API and find the relevant stats we need
        to populate the dashboard.
        """
        context = super(DashboardView, self).get_context_data(**kwargs)
        EmployeeAPI = Employee(token=self.token)

        context['user_name'] = self.user_name
        context['birthdays'] = EmployeeAPI.objects.filter(
            ordering="-birth_date")

        # position__sort doesn't seem to work too well
        context['positions'] = EmployeeAPI.objects.filter(ordering="-position")

        # all employees
        # Generator will discard values after iterating through them so
        # listify this to preserve data for later usuage.
        context['employees'] = list(
            EmployeeAPI.objects.filter(ordering="-user__first_name"))

        # calculate race groups
        race_groups = {}
        for emp in context['employees']:
            race = RACE_GROUPS[emp.race]
            if race in race_groups.keys():
                race_groups[race] += 1
            else:
                race_groups[race] = 1

        # sort by lowest to highest
        context['race_groups'] = OrderedDict(
            sorted(race_groups.items(), key=lambda k: k[1]))

        # calculate genders
        genders = {'Male': 0, 'Female': 0}

        for emp in context['employees']:
            gender = 'Male' if emp.gender == 'M' else 'Female'
            genders[gender] += 1

        # sort by lowest to highest
        context['genders'] = OrderedDict(
            sorted(genders.items(), key=lambda k: k[1]))
        return context
Example #17
0
    def post(self, request):
        username = request.POST.get('username')
        password = request.POST.get('password')
        try:
            # attempt to create a new user by authenticating against the API
            employee = Employee(username=username, password=password)

            # if the API failed for whatever reason get_token will be blank
            token = employee.objects.get_token()
            if token:
                request.session['token'] = token
                me = employee.objects.me()
                request.session['user_name'] = "%s %s" % (me.user.first_name,
                                                          me.user.last_name)
        except Exception as ex:
            return HttpResponseRedirect('/login')

        return HttpResponseRedirect('/')
Example #18
0
def update_employee_financial_details(csv_obj):
    with open(csv_obj.file_name.path, 'r') as f:
        reader = csv.reader(f)
        employees = []
        statutory_deductions = []
        non_statutory_deductions = []
        for i, row in enumerate(reader):
            if i < 2:  # Ignore first 2 rows
                pass
            else:
                employee_id = row[0]
                currency_code = row[2]
                basic_salary = row[3]
                bonus = row[4]
                local_service_allowance = row[5]
                meal_allowance = row[6]
                sacco = row[7]
                damage = row[8]
                salary_advance = row[9]
                police_fine = row[10]
                local_service_tax = row[11]

                employee = get_employee(employee_id)
                old_statutory_deduction = get_employee_statutory_deduction(employee)
                old_non_statutory_deduction = get_employee_deduction(employee)
                currency = get_currency_from_code(currency_code)
                new_employee = Employee(id=employee_id, currency=currency, basic_salary=basic_salary, bonus=bonus,
                                        local_service_tax=local_service_allowance,
                                        lunch_allowance=meal_allowance)
                employees.append(new_employee)
                new_statutory_deduction = StatutoryDeduction(id=old_statutory_deduction.id, employee=employee,
                                                             local_service_tax=local_service_tax)
                statutory_deductions.append(new_statutory_deduction)
                non_statutory_deduction = Deduction(id=old_non_statutory_deduction.id,
                                                    employee=employee, sacco=sacco, damage=damage,
                                                    salary_advance=salary_advance, police_fine=police_fine)
                non_statutory_deductions.append(non_statutory_deduction)

        Employee.objects.bulk_update(employees, ['currency', 'basic_salary', 'bonus', 'local_service_tax',
                                                 'lunch_allowance'])

        StatutoryDeduction.objects.bulk_update(statutory_deductions, ['local_service_tax'])
        Deduction.objects.bulk_update(non_statutory_deductions, ['sacco', 'damage', 'salary_advance', 'police_fine'])
Example #19
0
    def get(self, request):
        """
        Will only respond to ALL GET requests and
        return a list of all employees.
        """

        try:
            # attempt to create a new user by authenticating against the API
            employee = Employee(token=self.token)
            profile = employee.objects.me()
            return render(
                request, 'profile.html', {
                    'profile': profile,
                    'user_name': self.user_name,
                    'page_title': 'My Profile'
                })
        except Exception as ex:
            return HttpResponseRedirect('/dashboard')

        return HttpResponseRedirect('/dashboard')
def populate_db():
    environ.setdefault("DJANGO_SETTINGS_MODULE",
                       "newrelic_python_kata.settings")
    from employees.models import Employee, BioData, Payroll
    with open('names.txt') as f:
        es = []
        bs = []
        ps = []
        for idx, line in enumerate(f):
            name, sex, salary = line.rstrip('\r\n').split(',')
            e = Employee(name=name, employee_id=idx)
            b = BioData(employee=e, age=randint(18, 40), sex=sex)
            p = Payroll(employee=e, salary=salary)
            es.append(e)
            bs.append(b)
            ps.append(p)

    Employee.objects.bulk_create(es)
    BioData.objects.bulk_create(bs)
    Payroll.objects.bulk_create(ps)
Example #21
0
    def get(self, request):
        """
        Will only respond to ALL GET requests and
        return a list of all employees.
        """

        try:
            # attempt to create a new user by authenticating against the API
            employee = Employee(token=self.token)
            employees = employee.objects.filter(ordering="user__first_name")
            return render(
                request,
                self.template,
                {
                    'employees': employees,
                    'user_name': self.user_name,
                    'page_title': 'All Employees'
                }
            )
        except Exception as ex:
            return HttpResponseRedirect('/dashboard')

        return HttpResponseRedirect('/dashboard')
    def save(self):
        company = Company.objects.get(
            display_name=self.cleaned_data['company'])
        first_name = self.cleaned_data['first_name']
        last_name = self.cleaned_data['last_name']

        if self.cleaned_data['email']:
            username = f'{first_name.lower()}.{last_name.lower()}'
        else:
            username = self.cleaned_data['employee_id']

        new_employee = Employee(
            first_name=first_name,
            last_name=last_name,
            employee_id=self.cleaned_data['employee_id'],
            primary_phone=self.cleaned_data['primary_phone'],
            secondary_phone=self.cleaned_data['secondary_phone'],
            hire_date=self.cleaned_data['hire_date'],
            application_date=self.cleaned_data['application_date'],
            classroom_date=self.cleaned_data['classroom_date'],
            company=company,
            is_part_time=self.cleaned_data['is_part_time'],
            is_neighbor_link=self.cleaned_data['is_neighbor_link'],
            username=username,
            position=self.cleaned_data['position'],
            email=self.cleaned_data['email'])

        password = "******".format(
            self.cleaned_data['company'].upper(),
            self.cleaned_data['first_name'][0].upper(),
            self.cleaned_data['last_name'][0].upper(),
            str(self.cleaned_data['last4_ss']))

        new_employee.set_password(password)

        new_employee.save()

        return new_employee
def import_drivers(path):
    with ZipFile(path) as zipfile:
        try:
            driver_info = zipfile.read('drivers/drivers.xlsx')

            wb = load_workbook(filename=BytesIO(driver_info))
            try:
                sheet = wb['data']
                counter = 0
                for row in sheet.iter_rows(min_row=2):
                    try:
                        last_name = f'{row[0].value.lower()[0].upper()}{row[0].value.lower()[1:]}'
                        first_name = f'{row[1].value.lower()[0].upper()}{row[1].value.lower()[1:]}'
                        employee_id = row[2].value
                        position = row[3].value.lower()
                        hire_date = datetime.datetime.strptime(
                            str(row[4].value), '%Y%m%d')
                        application_date = datetime.datetime.strptime(
                            str(row[5].value), '%Y%m%d')
                        classroom_date = datetime.datetime.strptime(
                            str(row[6].value), '%Y%m%d')
                        company_name = row[7].value
                        is_part_time = True if row[8].value == 'TRUE' else False
                        primary_phone = row[9].value
                        secondary_phone = row[10].value
                        ss_number = row[11].value

                        company = Company.objects.get(
                            display_name=company_name)

                        new_employee = Employee(
                            first_name=first_name,
                            last_name=last_name,
                            employee_id=employee_id,
                            primary_phone=primary_phone,
                            secondary_phone=secondary_phone,
                            hire_date=hire_date,
                            application_date=application_date,
                            classroom_date=classroom_date,
                            company=company,
                            is_part_time=is_part_time,
                            username=employee_id,
                            position=position,
                            is_active=True,
                        )

                        password = f'{company}{first_name[0].upper()}{last_name[0].upper()}{ss_number}'

                        new_employee.set_password(password)

                        try:
                            profile_picture = BytesIO(
                                zipfile.read(
                                    f'drivers/pictures/{employee_id}.jpg'))
                            new_employee.profile_picture.save(
                                f'{employee_id}.jpg', profile_picture)
                        except KeyError:
                            pass

                        new_employee.save()
                        counter += 1
                    except:
                        pass
            except KeyError:
                pass
        except KeyError:
            pass
    try:
        os.remove(path)
    except FileNotFoundError:
        pass

    return f'Imported a total of {counter} employees'
Example #24
0
 def setUp(self):
     self.employee = Employee(name='user1',
                              department='Engineering',
                              hired_date='2017-08-27').save()
     self.url = url_for('employee_app.all_employees')
import random


def random_number(min, max, numbers=set()):
    number = random.randint(min, max)
    if number in numbers:
        while number in numbers:
            number = random.randint(min, max)
    numbers.add(number)
    return number


names = ['john', 'test', 'user', 'bot', 'someguy']
last_names = ['Doe', 'Kowalski', 'Smith', 'White']
hosts = ['gmail.com', 'yahoo.com', 'wp.pl', 'o2.pl']

professions = list(Profession.objects.all())

for i in range(20):

    name = random.choice(names)
    last_name = random.choice(last_names)
    email = '@'.join([name + str(random_number(0, 300)), random.choice(hosts)])

    e = Employee(name=name,
                 last_name=last_name,
                 email=email,
                 profession=random.choice(professions))
    # print(name, last_name, email)
    e.save()
def populate_employees(apps, schema_editor):
    d1 = Departament.objects.get(name__iexact='Отдел 1')
    d2 = Departament.objects.get(name__iexact='Отдел 2')
    d3 = Departament.objects.get(name__iexact='Отдел 3')
    e = Employee(name='Иван',
                 surname='Арбузов',
                 middle_name='Иванович',
                 birthday='1990-01-01',
                 email='[email protected]',
                 phone='+79999999999',
                 begin_work='2010-01-01',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Антонов',
                 middle_name='Иванович',
                 birthday='1990-01-01',
                 email='[email protected]',
                 phone='+79999999999',
                 begin_work='2010-01-01',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Богданов',
                 middle_name='Иванович',
                 birthday='1990-01-02',
                 email='[email protected]',
                 phone='+79999999998',
                 begin_work='2010-01-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Боряев',
                 middle_name='Иванович',
                 birthday='1990-01-02',
                 email='[email protected]',
                 phone='+79999999998',
                 begin_work='2010-01-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Ванков',
                 middle_name='Иванович',
                 birthday='1990-01-03',
                 email='[email protected]',
                 phone='+79999999997',
                 begin_work='2010-02-01',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Волков',
                 middle_name='Иванович',
                 birthday='1990-01-03',
                 email='[email protected]',
                 phone='+79999999997',
                 begin_work='2010-02-01',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Викторов',
                 middle_name='Иванович',
                 birthday='1990-01-03',
                 email='[email protected]',
                 phone='+79999999997',
                 begin_work='2010-02-01',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Городецкий',
                 middle_name='Иванович',
                 birthday='1990-01-04',
                 email='[email protected]',
                 phone='+79999999996',
                 begin_work='2010-02-01',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Домов',
                 middle_name='Иванович',
                 birthday='1990-01-05',
                 email='[email protected]',
                 phone='+79999999995',
                 begin_work='2010-03-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Дарьев',
                 middle_name='Иванович',
                 birthday='1990-01-05',
                 email='[email protected]',
                 phone='+79999999995',
                 begin_work='2010-03-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Дивеев',
                 middle_name='Иванович',
                 birthday='1990-01-05',
                 email='[email protected]',
                 phone='+79999999995',
                 begin_work='2010-03-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Дамков',
                 middle_name='Иванович',
                 birthday='1990-01-05',
                 email='[email protected]',
                 phone='+79999999995',
                 begin_work='2010-03-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Евалов',
                 middle_name='Иванович',
                 birthday='1990-01-06',
                 email='[email protected]',
                 phone='+79999999994',
                 begin_work='2010-03-01',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Жиров',
                 middle_name='Иванович',
                 birthday='1990-01-07',
                 email='[email protected]',
                 phone='+79999999993',
                 begin_work='2010-04-01',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Замков',
                 middle_name='Иванович',
                 birthday='1990-01-08',
                 email='[email protected]',
                 phone='+79999999992',
                 begin_work='2010-04-01',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Иванов',
                 middle_name='Иванович',
                 birthday='1990-01-09',
                 email='[email protected]',
                 phone='+79999999991',
                 begin_work='2010-05-01',
                 end_work='2014-01-01',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Копченов',
                 middle_name='Иванович',
                 birthday='1990-01-10',
                 email='[email protected]',
                 phone='+79999999990',
                 begin_work='2010-05-01',
                 end_work='2014-01-01',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Лунков',
                 middle_name='Иванович',
                 birthday='1990-01-11',
                 email='[email protected]',
                 phone='+79999999989',
                 begin_work='2010-06-01',
                 end_work='2014-01-02',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Марков',
                 middle_name='Иванович',
                 birthday='1990-01-12',
                 email='[email protected]',
                 phone='+79999999979',
                 begin_work='2010-06-01',
                 end_work='2014-01-02',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Норов',
                 middle_name='Иванович',
                 birthday='1990-01-13',
                 email='[email protected]',
                 phone='+79999999969',
                 begin_work='2010-07-01',
                 end_work='2014-01-03',
                 post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван',
                 surname='Орлов',
                 middle_name='Иванович',
                 birthday='1990-01-14',
                 email='[email protected]',
                 phone='+79999999959',
                 begin_work='2010-07-01',
                 end_work='2014-01-03',
                 post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван',
                 surname='Петров',
                 middle_name='Иванович',
                 birthday='1990-01-15',
                 email='[email protected]',
                 phone='+79999999949',
                 begin_work='2010-08-01',
                 end_work='2014-01-04',
                 post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван',
                 surname='Ростов',
                 middle_name='Иванович',
                 birthday='1990-01-16',
                 email='[email protected]',
                 phone='+79999999939',
                 begin_work='2010-08-01',
                 end_work='2014-01-04',
                 post='разработчик',
                 departament=d1)
    e.save()
Example #27
0
 def tearDown(self):
     Employee.drop_collection()
Example #28
0
 def test_employee_str(self):
     est_test = Establishment(name="Vaflia project")
     emp_test = Employee(establishment=est_test)
     self.assertEqual(emp_test.__str__(), 'Аккаунт Vaflia project')
def populate_employees(apps, schema_editor):
    d1 = Departament.objects.get(name__iexact='Отдел 1')
    d2 = Departament.objects.get(name__iexact='Отдел 2')
    d3 = Departament.objects.get(name__iexact='Отдел 3')
    e = Employee(name='Иван', surname='Арбузов', middle_name='Иванович', birthday='1990-01-01', email='[email protected]',
                 phone='+79999999999', begin_work='2010-01-01', post='разработчик', departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Антонов', middle_name='Иванович', birthday='1990-01-01', email='[email protected]',
                 phone='+79999999999', begin_work='2010-01-01', post='разработчик', departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Богданов', middle_name='Иванович', birthday='1990-01-02', email='[email protected]',
                 phone='+79999999998', begin_work='2010-01-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Боряев', middle_name='Иванович', birthday='1990-01-02', email='[email protected]',
                 phone='+79999999998', begin_work='2010-01-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Ванков', middle_name='Иванович', birthday='1990-01-03', email='[email protected]',
                 phone='+79999999997', begin_work='2010-02-01', post='разработчик', departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Волков', middle_name='Иванович', birthday='1990-01-03', email='[email protected]',
                 phone='+79999999997', begin_work='2010-02-01', post='разработчик', departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Викторов', middle_name='Иванович', birthday='1990-01-03', email='[email protected]',
                 phone='+79999999997', begin_work='2010-02-01', post='разработчик', departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Городецкий', middle_name='Иванович', birthday='1990-01-04', email='[email protected]',
                 phone='+79999999996', begin_work='2010-02-01', post='разработчик', departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Домов', middle_name='Иванович', birthday='1990-01-05', email='[email protected]',
                 phone='+79999999995', begin_work='2010-03-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Дарьев', middle_name='Иванович', birthday='1990-01-05', email='[email protected]',
                 phone='+79999999995', begin_work='2010-03-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Дивеев', middle_name='Иванович', birthday='1990-01-05', email='[email protected]',
                 phone='+79999999995', begin_work='2010-03-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Дамков', middle_name='Иванович', birthday='1990-01-05', email='[email protected]',
                 phone='+79999999995', begin_work='2010-03-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Евалов', middle_name='Иванович', birthday='1990-01-06', email='[email protected]',
                 phone='+79999999994', begin_work='2010-03-01', post='разработчик', departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Жиров', middle_name='Иванович', birthday='1990-01-07', email='[email protected]',
                 phone='+79999999993', begin_work='2010-04-01', post='разработчик', departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Замков', middle_name='Иванович', birthday='1990-01-08', email='[email protected]',
                 phone='+79999999992', begin_work='2010-04-01', post='разработчик', departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Иванов', middle_name='Иванович', birthday='1990-01-09', email='[email protected]',
                 phone='+79999999991', begin_work='2010-05-01', end_work='2014-01-01', post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Копченов', middle_name='Иванович', birthday='1990-01-10', email='[email protected]',
                 phone='+79999999990', begin_work='2010-05-01', end_work='2014-01-01', post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Лунков', middle_name='Иванович', birthday='1990-01-11', email='[email protected]',
                 phone='+79999999989', begin_work='2010-06-01', end_work='2014-01-02', post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Марков', middle_name='Иванович', birthday='1990-01-12', email='[email protected]',
                 phone='+79999999979', begin_work='2010-06-01', end_work='2014-01-02', post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Норов', middle_name='Иванович', birthday='1990-01-13', email='[email protected]',
                 phone='+79999999969', begin_work='2010-07-01', end_work='2014-01-03', post='разработчик',
                 departament=d1)
    e.save()
    e = Employee(name='Иван', surname='Орлов', middle_name='Иванович', birthday='1990-01-14', email='[email protected]',
                 phone='+79999999959', begin_work='2010-07-01', end_work='2014-01-03', post='разработчик',
                 departament=d2)
    e.save()
    e = Employee(name='Иван', surname='Петров', middle_name='Иванович', birthday='1990-01-15', email='[email protected]',
                 phone='+79999999949', begin_work='2010-08-01', end_work='2014-01-04', post='разработчик',
                 departament=d3)
    e.save()
    e = Employee(name='Иван', surname='Ростов', middle_name='Иванович', birthday='1990-01-16', email='[email protected]',
                 phone='+79999999939', begin_work='2010-08-01', end_work='2014-01-04', post='разработчик',
                 departament=d1)
    e.save()
Example #30
0
def funcionario():
    file = open("/maladireta/database/funcionarios.csv")
    count = 0
    for line in file.readlines():
        dados = line.split(',')
        employee = Employee()
        for i in range(len(dados)):
            if i == 1:
                employee.name = dados[i]
            elif i == 2:
                employee.nickname = dados[i]
            elif i == 3:
                employee.phone_number = dados[i]
            elif i == 4:
                employee.cellphone = dados[i]
            elif i == 5:
                employee.street = dados[i]
            elif i == 6:
                employee.neighborhood = dados[i]
            elif i == 7:
                employee.city = dados[i]
            elif i == 8:
                employee.cep = dados[i]
            elif i == 9:
                employee.email = dados[i]
            elif i == 10:
                employee.function = dados[i]
            elif i == 12:
                employee.note = dados[i]
            elif i == 14:
                employee.birth = to_datetime(date=dados[i])
            elif i == 15:
                employee.state = dados[i]
            elif i == 17:
                employee.number = dados[i].split("\n")[0]
            employee.save()
            count = count + 1
    print("{} funcionários adicionados".format(count))
Example #31
0
 def setUp(self):
     for i in range(10):
         self.employee = Employee(name='user{}'.format(i),
                                  department='Engineering',
                                  hired_date='2017-08-27').save()
     self.url = url_for('employee_app.make_groups')
Example #32
0
def profile_ee(request):
    employee = Employee.objects.values_list('uid', flat=True)
    #print(employee)
    current_user = request.user.username
    #print(current_user)
    if current_user in employee:
        if request.method == 'POST': # and request.FILES['uid_photo_front'] and request.FILES['uid_photo_back'] and request.FILES['self_photo']:
        #save attachment Aadhar front 
            print('1')
            '''if request.FILES['uid_photo_front']:
                print('2')
                uid_photo_front = request.FILES['uid_photo_front']
                fs1 = FileSystemStorage()
                filename1 = fs1.save(uid_photo_front.name, uid_photo_front)
                uploaded_file_url1 = fs.url(filename1)
            else:
                print('3')
                uid_photo_front = request.POST.get('uid_photo_front')
            #save attachment Aadhar back 
            if (request.FILES['uid_photo_back']):
                print('4')
                uid_photo_back = request.FILES['uid_photo_back']
                fs2 = FileSystemStorage()
                filename2 = fs2.save(uid_photo_back.name, uid_photo_back)
                uploaded_file_url2 = fs.url(filename2)
            else:
                uid_photo_back = request.POST.get('uid_photo_back')

            #save attachment self photo 
            if (request.FILES['self_photo']):
                self_photo = request.FILES['self_photo']
                fs3 = FileSystemStorage()
                filename3 = fs3.save(self_photo.name, self_photo)
                uploaded_file_url3 = fs.url(filename3)
            else:
                self_photo = request.POST.get('self_photo')
            '''
            #get field inputs
            volunteer = request.POST.get('volunteer')
            uid = request.POST.get('uid')
            first_name = request.POST.get('first_name')
            last_name = request.POST.get('last_name')
            age = request.POST.get('age')
            gender = request.POST.get('gender')
            city = request.POST.get('city')
            phone = request.POST.get('phone')
            job_preference1 = request.POST.get('job_preference1')
            job_preference2 = request.POST.get('job_preference2')
            job_preference3 = request.POST.get('job_preference3')
            is_experienced = request.POST.get('is_experienced')
            prev_work_exp = request.POST.get('prev_work_exp')
            qualification = request.POST.get('qualification')
            exp_salary = request.POST.get('exp_salary')
            exp_salary_frequency = request.POST.get('exp_salary_frequency')
            pref_shift = request.POST.get('pref_shift')
            pref_location = request.POST.get('pref_location')
            #uid_photo_front = request.POST.get('uid_photo_front')
            #uid_photo_back = request.POST.get('uid_photo_back')
            #self_photo = request.POST.get('self_photo')
            # Check Age if the employee
            get_employee = Employee.objects.get(uid=current_user)
            #volunteer = request.POST['volunteer']
            volunteer_id = Volunteer.objects.get(name=volunteer)
            job1 = Job.objects.get(job_name=job_preference1)
            job2 = Job.objects.get(job_name=job_preference2)
            job3 = Job.objects.get(job_name=job_preference3)
            get_employee.volunteer = volunteer_id
            get_employee.first_name = first_name
            get_employee.last_name = last_name 
            get_employee.age = age
            get_employee.gender = gender
            get_employee.city = city
            get_employee.phone = phone
            get_employee.job_preference1 = job1
            get_employee.job_preference2 = job2
            get_employee.job_preference3 = job3
            get_employee.is_experienced = is_experienced
            get_employee.prev_work_exp = prev_work_exp
            get_employee.qualification = qualification
            get_employee.exp_salary = exp_salary
            get_employee.exp_salary_frequency = exp_salary_frequency
            get_employee.pref_shift = pref_shift
            get_employee.pref_location = pref_location
            '''if uid_photo_front:
                get_employee.uid_photo_front = uid_photo_front
            if uid_photo_back:
                get_employee.uid_photo_back = uid_photo_back
            if self_photo:
                get_employee.self_photo = self_photo
            '''
            get_employee.save()
            messages.success(request, 'Your profile is updated successfully')
            return HttpResponseRedirect('dashboard')
        else:
            employee = Employee.objects.get(uid=current_user)
            print(employee.is_experienced)
            volunteer_list = Volunteer.objects.all()
            job_list = Job.objects.all()
            #employee_form = EmployeeForm()
            context = {
            #    'employee_form': employee_form,
                'salary_choices': Employee.SALARY_CHOICES,
                'gender_choices': Employee.GENDER_CHOICES,
                'qualification_choices': Employee.QUALIFICATION_CHOICES,
                'shift_choices': Employee.SHIFT_OFFERED_CHOICES,
                'volunteers': volunteer_list,
                'jobs': job_list,
                'employee' : employee
                }
            
            return render(request, 'accounts/profile_ee.html', context)
    else:
        if request.method == 'POST' and request.FILES['uid_photo_front'] and request.FILES['uid_photo_back'] and request.FILES['self_photo']:
        #save attachment Aadhar front 
            print('1')
            if (request.FILES['uid_photo_front']):
                print('2')
                uid_photo_front = request.FILES['uid_photo_front']
                fs1 = FileSystemStorage()
                filename1 = fs1.save(uid_photo_front.name, uid_photo_front)
                uploaded_file_url1 = fs1.url(filename1)
            else:
                print('3')
                uid_photo_front = request.POST.get('uid_photo_front')
            #save attachment Aadhar back 
            if (request.FILES['uid_photo_back']):
                print('4')
                uid_photo_back = request.FILES['uid_photo_back']
                fs2 = FileSystemStorage()
                filename2 = fs2.save(uid_photo_back.name, uid_photo_back)
                uploaded_file_url2 = fs2.url(filename2)
            else:
                uid_photo_back = request.POST.get('uid_photo_back')

            #save attachment self photo 
            if (request.FILES['self_photo']):
                self_photo = request.FILES['self_photo']
                fs3 = FileSystemStorage()
                filename3 = fs3.save(self_photo.name, self_photo)
                uploaded_file_url3 = fs3.url(filename3)
            else:
                self_photo = request.POST.get('self_photo')
            
            #get field inputs
            volunteer = request.POST.get('volunteer')
            uid = request.POST.get('uid')
            first_name = request.POST.get('first_name')
            last_name = request.POST.get('last_name')
            age = request.POST.get('age')
            gender = request.POST.get('gender')
            city = request.POST.get('city')
            phone = request.POST.get('phone')
            job_preference1 = request.POST.get('job_preference1')
            job_preference2 = request.POST.get('job_preference2')
            job_preference3 = request.POST.get('job_preference3')
            is_experienced = request.POST.get('is_experienced')
            prev_work_exp = request.POST.get('prev_work_exp')
            qualification = request.POST.get('qualification')
            exp_salary = request.POST.get('exp_salary')
            exp_salary_frequency = request.POST.get('exp_salary_frequency')
            pref_shift = request.POST.get('pref_shift')
            pref_location = request.POST.get('pref_location')
            condition_agreed = request.POST.get('condition_agreed', False)
            #uid_photo_front = request.POST.get('uid_photo_front')
            #uid_photo_back = request.POST.get('uid_photo_back')
            #self_photo = request.POST.get('self_photo')
            # Check Age if the employee
            age=int(age)
            if age<18:
                messages.error(request, 'You are not eligible to apply as per the Child Labour Law since you are less than 18 years old.')
                print(request)
                
                return redirect('index')

            else:
                volunteer_id = Volunteer.objects.get(name=volunteer)
                job1 = Job.objects.get(job_name=job_preference1)
                job2 = Job.objects.get(job_name=job_preference2)
                job3 = Job.objects.get(job_name=job_preference3)

                new_employee = Employee(volunteer=volunteer_id, uid = uid,
                first_name = first_name,
                last_name = last_name,
                age = age,
                gender = gender,
                city = city,
                phone = phone,
                job_preference1 = job1,
                job_preference2 = job2,
                job_preference3 = job3,
                is_experienced = is_experienced,
                prev_work_exp = prev_work_exp,
                qualification = qualification,
                exp_salary = exp_salary,
                exp_salary_frequency = exp_salary_frequency,
                pref_shift = pref_shift,
                pref_location = pref_location,
                uid_photo_front = uid_photo_front,
                uid_photo_back = uid_photo_back,
                self_photo = self_photo,
                condition_agreed= condition_agreed)
                new_employee.save()

                context = {
                'current_user' : current_user,
                'phone' : phone
                }

                messages.success(request, 'Your profile is updated successfully')
                return render( request, 'accounts/validate_phone.html', context)
        else:
            volunteer_list = Volunteer.objects.all()
            job_list = Job.objects.all()
            context = {
            #    'employee_form': employee_form,
                'salary_choices': Employee.SALARY_CHOICES,
                'gender_choices': Employee.GENDER_CHOICES,
                'qualification_choices': Employee.QUALIFICATION_CHOICES,
                'shift_choices': Employee.SHIFT_OFFERED_CHOICES,
                'volunteers': volunteer_list,
                'jobs': job_list,
                }
            return render(request, 'accounts/profile_ee.html', context)