コード例 #1
0
def load_database():
    '''
    Initialize all objects stored in data/..
    Close program if there is not enough database to function properly.

    Parameters, Returns: None

    Initialize:
        Student objs.
        Mentor objs.
        Employee objs.
        Manager objs.
        Assigments objs.
        Logins.list_of_logins
    '''
    Assignment.get_assignments_from_file('assignments.csv')
    Attendance.get_attendance_from_file('attendance.csv')
    Student.get_codecoolers_from_file('students.csv')
    Employee.get_codecoolers_from_file('employees.csv')
    Mentor.get_codecoolers_from_file('mentors.csv')
    Manager.get_codecoolers_from_file('managers.csv')

    if len(Manager.list_of_managers) < 1 or len(
            Employee.list_of_employees) < 1:
        err_msg = 'There is no database stored. Contact our support at [email protected]'
        view.print_message(err_msg)
        sys.exit()

    Logins.from_codecoolers(Student.list_of_students,
                            Employee.list_of_employees,
                            Manager.list_of_managers, Mentor.list_of_mentors)
コード例 #2
0
def create_employee():
    employee = Employee()
    data = json.loads(request.data)
    update_employee_info(employee, data)
    db_session.add(employee)
    db_session.commit()
    return jsonify(employee.to_dict())
コード例 #3
0
ファイル: employees.py プロジェクト: joegillon/allocat
def emp_add():
    values = json.loads(request.form['params'])
    try:
        empid = Employee.add(values)
    except Exception as ex:
        return jsonify(error=str(ex))
    return jsonify(empid=empid, employees=Employee.get_all())
コード例 #4
0
ファイル: employees.py プロジェクト: joegillon/allocat
def emp_drop():
    empid = json.loads(request.args['empid'])
    success = Employee.delete(empid)
    if not success:
        msg = 'Record not deleted for unknown reason. Contact admin.'
        return jsonify(error=msg)
    data = Employee.get_all()
    return jsonify(employees=data)
コード例 #5
0
 def get(self):
     return (
         {
             "success": True,
             "employees":
             [Employee.json(emp) for emp in Employee.find_all()],
         },
         200,
     )
コード例 #6
0
    def add_model(self, form_values):
        new_model = Employee(self.get_new_model_values(form_values))

        try:
            new_model.id = new_model.add(Dao())
        except Exception as ex:
            uil.show_error(str(ex))
            return

        uil.show_msg('Employee added!', 'Hallelujah!')
コード例 #7
0
ファイル: employees.py プロジェクト: joegillon/allocat
def emp_update():
    values = json.loads(request.form['params'])
    empid = values['id']
    try:
        numrows = Employee.update(values)
        if numrows != 1:
            msg = 'Record not updated for unknown reason. Contact admin.'
            return jsonify(error=msg)
    except Exception as ex:
        return jsonify(error=str(ex))
    return jsonify(empid=empid, employees=Employee.get_all())
コード例 #8
0
 def all_employee(self):  # Retrieve all employees from employee and return
     sql = "SELECT * FROM employee"
     cursor = connection.cursor()
     cursor.execute(sql)
     records = cursor.fetchall()
     emp_list = []
     for record in records:
         employee = Employee(record[0], record[1], record[2], record[3],
                             record[4], record[5], record[6], record[7],
                             record[8], record[9])
         emp_list.append(employee.json())
     return emp_list
コード例 #9
0
    def get_all_records(self):
        sql = "SELECT * FROM employees"
        cursor = connection.cursor()
        cursor.execute(sql)
        records = cursor.fetchall()

        employee_list = []
        for record in records:
            employee = Employee(record[0])
            employee_list.append(employee.json())

        return employee_list
コード例 #10
0
    def get_employee(id):
        sql = "Select * from employees where id = %s"
        cursor = connection.cursor()
        cursor.execute(sql, [id])
        record = cursor.fetchone()
        employee = Employee(id=record[0],
                            first_name=record[1],
                            last_name=record[2],
                            login_id=record[3])
        employee.department = DepartmentDao.get_department(record[4])
        employee.role = RoleDao.get_role(record[5])

        return employee
コード例 #11
0
 def test_get_all(self):
     self.assertEqual(crud.Employees.get_all(), [
         Employee(id=1,
                  name='Steven Gray',
                  department_id=10001,
                  date_of_birthday=date(1997, 10, 1),
                  salary=Decimal(1000)),
         Employee(id=2,
                  name='John Spins',
                  department_id=10001,
                  date_of_birthday=date(1997, 5, 11),
                  salary=Decimal(3000))
     ])
コード例 #12
0
    def create_employee(self, employee):  # Create new Employee
        sql = "INSERT INTO employee VALUES(DEFAULT, %s, %s, %s , %s ,%s, %s , %s, %s, %s) RETURNING *"
        cursor = connection.cursor()
        cursor.execute(sql, [
            employee.firstname, employee.midname, employee.lastname,
            employee.email, employee.address, employee.emprole,
            employee.username, employee.password, employee.phone
        ])
        connection.commit()
        record = cursor.fetchone()

        return Employee(
            Employee(record[0], record[1], record[2], record[3], record[4],
                     record[5], record[6], record[7], record[8],
                     record[9]).json())
コード例 #13
0
def get_employee():
    """Gets employee name for purpose of creating time entry.

    Asks user for employee name, determines whether name already exists,
    returns employee name as a string.
    """

    employee_name = input("Employee Name \n" +
                          "Please enter employee's name: ").strip()
    try:
        employee = Employee.create(name=employee_name)
    except IntegrityError:
        employee = Employee.get(Employee.name == employee_name)

    return employee
コード例 #14
0
    def all_employees(self):
        sql = "SELECT * FROM employees"
        cursor = connection.cursor()
        cursor.execute(sql)
        records = cursor.fetchall()
        log(f"Viewing employees")
        employee_list = []

        for record in records:
            employee = Employee(record[0], record[1], record[2], record[3],
                                record[4], record[5], record[6])

            employee_list.append(employee.json())

        return employee_list
コード例 #15
0
    def get_employees_by_department(department_id):
        sql = "Select * from employees where department_id = %s"
        cursor = connection.cursor()
        cursor.execute(sql, [department_id])
        records = cursor.fetchall()
        employees = []

        for record in records:
            employee = Employee(id=record[0],
                                first_name=record[1],
                                last_name=record[2],
                                login_id=record[3])
            employee.role = RoleDao.get_role(record[5])
            employees.append(employee)
        return employees
コード例 #16
0
 def setUp(self):
     app.config.from_object(TestConfiguration)
     self.app = app.test_client()
     db.create_all()
     db.session.add(Department(id=10001, name='Test Department'))
     db.session.add(
         Employee(name='Steven Gray',
                  department_id=10001,
                  date_of_birthday=date(1997, 10, 1),
                  salary=Decimal(1000)))
     db.session.add(
         Employee(name='John Spins',
                  department_id=10001,
                  date_of_birthday=date(1997, 5, 11),
                  salary=Decimal(3000)))
     db.session.commit()
コード例 #17
0
    def add(name, department_id, date_of_birthday, salary):
        """
        Adds new employee

        :param string name: Employee`s full name
        :param int department_id: Employee`s department number
        :param date date_of_birthday: Employee`s date of birthday
        :param float salary: Employee`s salary
        :return: new employee who has been added
        :rtype: Employee
        """
        if Department.query.filter_by(id=department_id).first() is None:
            logger.debug(f'Department isn`t exist. Employee can`t be added')
            raise AttributeError
        try:
            employee = Employee(name=name,
                                department_id=department_id,
                                date_of_birthday=date_of_birthday,
                                salary=salary)
        except:
            logger.debug(f'Incorrect data. Employee can`t be added')
            raise ValueError
        db.session.add(employee)
        db.session.commit()
        logger.debug(f'Employee was added')
        return employee
コード例 #18
0
 def get(self):
     year = request.args.get("year")
     month = request.args.get("month")
     day = request.args.get("day")
     if year is None:
         return {"msg", "Please provide the year in the query param."}, 400
     else:
         year = int(year) if len(year) > 0 else 0
     if month is None:
         return (
             {"msg", "Please provide the month in the query param."},
             400,
         )
     else:
         month = int(month) if len(month) > 0 else 0
     if day is None:
         day = 0
     else:
         day = int(day) if len(day) > 0 else 0
     entries = []
     employee_ids = [row["id"] for row in Employee.get_employee_ids()]
     for _id in employee_ids:
         emp_entries = get_entries(_id, year, month, day)
         if len(emp_entries) > 0:
             entries.append(emp_entries)
     response = Response(generate(entries))
     response.headers.set("Content-Disposition",
                          "attachment",
                          filename="export.csv")
     return response
コード例 #19
0
ファイル: employee_test.py プロジェクト: sharan1/love
    def test_get_current_employee(self, mock_get_current_user):
        employee = create_employee(username='******')
        mock_get_current_user.return_value = employee.user
        current_employee = Employee.get_current_employee()

        self.assertIsNotNone(current_employee)
        self.assertEqual('john.d', current_employee.username)
コード例 #20
0
    def get_groups(self, userid, request):
        """Return a list of principals for userid.

        If userid represents a non-manager then the list of principals returned
        is emp:<userid>

        If the user is a manager then the list of principals returned further
        includes principals of the form:
            emp_mgr:FOO.emp_no
        for each FOO employee in the dept. managed by the user AND
            dept_mgr:DEPT.dept_no
        where DEPT is the dept_no of the dept. managed by the user.

        This results in a larger number of principals but avoids having to look
        up the DB (to resolve department-manager relationships) each time a
        request to an employee or department resource is made.
        """
        LOG.debug("Getting principal info for:{}".format(userid))
        employee = Employee.get_by_number(userid)
        if employee.curr_managed_dept is not None:
            principals = [self.dept_mgr_p(employee.curr_managed_dept.dept_no)]
            curr_emps = employee.curr_managed_dept.curr_employee_refs.all()
            # curr_emps will include userid too
            principals.extend([self.emp_mgr_p(emp_ref.emp_no)
                                 for emp_ref in curr_emps])
            LOG.debug("Returning principals:{}".format(principals))
            return principals
        else:
            principals = [self.emp_p(userid)]
            LOG.debug("Returning principals:[{}]".format(principals))
            return principals
コード例 #21
0
def save_data():
    emp_name = request.form.get('emp_name')
    emp_code = request.form.get('emp_code')
    emp_email = request.form.get('emp_email')
    job_function = request.form.get('job_function')
    date = request.form.get('date')
    reviewer_name = request.form.get('reviewer_name')
    reviewer_code = request.form.get('reviewer_code')
    self_assessment1 = request.form.get('self_assessment1')
    self_assessment1_comment1 = request.form.get('self_assessment1_comment1')
    self_assessment2 = request.form.get('self_assessment2')
    self_assessment2_comment2 = request.form.get('self_assessment2_comment2')
    self_assessment3 = request.form.get('self_assessment3')
    self_assessment3_comment3 = request.form.get('self_assessment3_comment3')
    self_assessment4 = request.form.get('self_assessment4')
    self_assessment4_comment4 = request.form.get('self_assessment4_comment4')
    self_assessment5 = request.form.get('self_assessment5')
    self_assessment5_comment5 = request.form.get('self_assessment5_comment5')
    self_assessment6 = request.form.get('self_assessment6')
    self_assessment6_comment6 = request.form.get('self_assessment6_comment6')
    rev_email = request.form.get('rev_email')

    employee_form = Employee(
        emp_code=emp_code,
        emp_name=emp_name,
        emp_email=emp_email,
        job_function=job_function,
        date=date,
        reviewer_name=reviewer_name,
        reviewer_code=reviewer_code,
        self_assessment1=self_assessment1,
        self_assessment1_comment1=self_assessment1_comment1,
        self_assessment2=self_assessment2,
        self_assessment2_comment2=self_assessment2_comment2,
        self_assessment3=self_assessment3,
        self_assessment3_comment3=self_assessment3_comment3,
        self_assessment4=self_assessment4,
        self_assessment4_comment4=self_assessment4_comment4,
        self_assessment5=self_assessment5,
        self_assessment5_comment5=self_assessment5_comment5,
        self_assessment6=self_assessment6,
        self_assessment6_comment6=self_assessment6_comment6,
        rev_email=rev_email,
        IP_addr=request.remote_addr,
        Location=request.form.get('location'),
        UserAgent=request.user_agent.browser,
        OperatingSystem=request.user_agent.platform,
        Time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )

    db.session.add(employee_form)
    db.session.commit()
    utils.send_link_as_mail(
        emp_name=emp_name,
        # emp_email=emp_email,
        rev_email=rev_email,
        reviewer_code=reviewer_code,
        emp_code=emp_code,
    )
    return redirect('/success')
コード例 #22
0
def run_browse_by_name_process():
    """Executes employee name search on existing entries.

    Presents user with list of employees who have created entries.
    Allows user to view entries created by one of the employees listed.
     """

    list_of_employees = Employee.select()

    if len(list_of_employees) == 0:
        print("There are no time entries in the database.")
        dummy = input("Press Enter to continue.: > ")
        clear_screen()

    else:
        print("The following employees have created time entries:")
        print("")
        for employee in list_of_employees:
            print("\t" + employee.name)

        print("")
        selection = input("Which employee's time " +
                          "entries would you like to view? > ").strip()

        selection = validate_employee_name(selection, list_of_employees)

        matching_entries = (Time_Entry.select()
                                      .join(Employee)
                                      .where(Employee.name == selection))
        clear_screen()

        run_options_loop(matching_entries)
コード例 #23
0
ファイル: auth.py プロジェクト: shaikmalikbasha/cos-app
    def post(self):

        body = request.get_json()
        email = body["email"]
        password = body["password"]

        if email is None:
            return {"msg": "email field is mandatory"}, 400
        if password is None:
            return {"msg": "password field is mandatory"}, 400

        emp = Employee.find_by_email(email)
        if not emp:
            return {"msg": f"employee not found with email: {email}."}, 404
        authorized = emp.check_password(password)
        if not authorized:
            return {"msg": f"wrong password"}, 401
        roles = []
        for row in Role.get_roles_by_emp_id(emp.json()["id"]):
            roles.append(row["name"])
        access_token = create_access_token(identity={
            "email": emp.email,
            "roles": roles
        })
        return {"access_token": access_token, "roles": roles}, 200
コード例 #24
0
    def post(self):

		json_string = self.request.body
		dict_object = json.loads(json_string)

		employee_id = int( dict_object['employeeId'] ) 
		employee_name = dict_object['employeeName']
		employee_phone = dict_object['employeePhone']
		employee_carrier = dict_object['employeeCarrier']
		employee_bartending = bool( dict_object['employeeBartending'] )

		employee = Employee.get_by_id(employee_id)

		if employee != None:
			employee.name = employee_name
			employee.phone = employee_phone
			employee.carrier = employee_carrier
			employee.bartending = employee_bartending

			employee.put()

			res = { "msg" : "Employee successfully updated", "success": True, "employee_id" : employee_id }
			self.response.out.write(json.dumps(res))
		else:
			res = { "msg" : "Oops! Something went wrong. Please try again.", "success": False, "employee_id" : employee_id }
			self.response.out.write(json.dumps(res))
コード例 #25
0
def edit_employee_api(id):
    error = context.repository.edit_employee(
        Employee.from_tuple([id] + request.data.decode("utf-8").split(",")))
    if error:
        return error, 418
    context.repository.commit()
    return "", 204
コード例 #26
0
def get_employees_by_location(location_id):

    with sqlite3.connect("./kennel.db") as conn:
        conn.row_factory = sqlite3.Row
        db_cursor = conn.cursor()

        # Write the SQL query to get the information you want
        db_cursor.execute(
            """
        select
            e.id,
            e.name,
            e.address,
            e.location_id
        FROM Employee e
        WHERE e.location_id = ?
        """, (location_id, ))

        employees = []
        dataset = db_cursor.fetchall()

        for row in dataset:
            employee = Employee(row['id'], row['name'], row['address'],
                                row['location_id'])
            employees.append(employee.__dict__)

    return json.dumps(employees)
コード例 #27
0
def get_all_employees():
    with sqlite3.connect("./kennel.db") as conn:

        conn.row_factory = sqlite3.Row
        db_cursor = conn.cursor()

        db_cursor.execute("""
        SELECT
            e.id,
            e.name,
            e.address,
            e.location_id
        FROM Employee e
        """)

        employees = []

        dataset = db_cursor.fetchall()

        for row in dataset:

            employee = Employee(row['id'], row['name'], row['address'],
                                row['location_id'])

            employees.append(employee.__dict__)

    return json.dumps(employees)
コード例 #28
0
def loggin():

    if current_user.is_authenticated:
        return redirect(url_for('home'))

    password_to_check = request.form.get('password')
    username = request.form.get('username')

    user = Employee.get_or_none(Employee.username == username)

    if not user:
        flash(
            "We don't seem to have you in our system. Please doublecheck your name."
        )
        return redirect(url_for('sessions.new'))

    hashed_password = user.password

    if not check_password_hash(hashed_password, password_to_check):
        flash("That password is incorrect")
        return redirect(url_for('sessions.new'))

    login_user(user)
    flash('Login Successful', 'success')
    return redirect(url_for('home'))
コード例 #29
0
 def get(self):
     year = request.args.get("year")
     month = request.args.get("month")
     day = request.args.get("day")
     if year is None:
         return {"msg", "Please provide the year in the query param."}, 400
     else:
         year = int(year) if len(year) > 0 else 0
     if month is None:
         return (
             {"msg", "Please provide the month in the query param."},
             400,
         )
     else:
         month = int(month) if len(month) > 0 else 0
     if day is None:
         day = 0
     else:
         day = int(day) if len(day) > 0 else 0
     entries = []
     employee_ids = [row["id"] for row in Employee.get_employee_ids()]
     for _id in employee_ids:
         emp_entries = get_entries(_id, year, month, day)
         if len(emp_entries) > 0:
             entries.append(emp_entries)
     return {"entries": entries}, 200
コード例 #30
0
    def create_record(self, employee, fk1=None, fk2=None):
        sql = "INSERT INTO employees VALUES (%s) RETURNING *"

        cursor = connection.cursor()
        cursor.execute(sql, [employee.username])
        connection.commit()
        record = cursor.fetchone()
        return Employee(record[0])
コード例 #31
0
 def login(login_id):
     sql = "Select * from employees where login_id = %s"
     cursor = connection.cursor()
     cursor.execute(sql, [login_id])
     record = cursor.fetchone()
     if record:
         employee = Employee(id=record[0],
                             first_name=record[1],
                             last_name=record[2],
                             login_id=record[3])
         employee.department = DepartmentDao.get_department(record[4])
         employee.role = RoleDao.get_role(record[5])
         if record[6]:
             employee.supervisor = EmployeeDao.get_employee(record[6])
         return employee
     else:
         return False
コード例 #32
0
	def get(self):
		userName = self.request.get('userName')
		password = self.request.get('password')
		employee = Employee.query(Employee.userName == userName).get()
		if not employee or not employee.checkPassword(password) or employee.isManager:
			self.response.write("Wrong username or password or you are manager")
			return
		
		self.response.set_cookie('our_token', str(employee.key.id()))
		self.response.write(json.dumps({'status':'OK'}))
コード例 #33
0
    def get(self):
		userName = None
		if self.request.cookies.get('our_token'):    #the cookie that should contain the access token!
			userName = Employee.checkToken(self.request.cookies.get('our_token'))

		template_variables = {}
		if userName:
			template_variables['userName'] = userName.userName
		
		html = template.render("web/templates/LoginPage.html", template_variables)
		self.response.write(html)
コード例 #34
0
ファイル: projects.py プロジェクト: joegillon/allocat
def prj_list():
    projects = Project.get_all()
    emp_rex = Employee.get_all()
    employees = [{'id': employee['id'], 'value': employee['name']} for employee in emp_rex]

    is_authenticated = session['is_authenticated'] if 'is_authenticated' in session else False
    page = 'projects.html' if is_authenticated else 'projects_ro.html'

    return render_template(
        page,
        title='allocat projects',
        projects=projects,
        employees=employees
    )
コード例 #35
0
	def get(self, args=None):
		employee_id = self.request.get('employee_id')
		if not employee_id:
			self.response.write("the id field is empty!")
			return
		
		employee = Employee.query(Employee.workerID == employee_id).get()
		
		if not employee:
			self.response.write("there is no employee with this id number!")
			return
			
		employee.key.delete()
		
		self.response.write(json.dumps({'status':'OK'}))
コード例 #36
0
ファイル: employees.py プロジェクト: joegillon/allocat
def emp_list():
    employees = Employee.get_all()
    prj_rex = Project.get_all()
    projects = [
        {
            'id': project['id'],
            'value': project['nickname'],
            'first_month': project['first_month'],
            'last_month': project['last_month']
        } for project in prj_rex]

    is_authenticated = session['is_authenticated'] if 'is_authenticated' in session else False
    page = 'employees.html' if is_authenticated else 'employees_ro.html'

    return render_template(
        page,
        title='allocat employees',
        projects=projects,
        employees=employees
    )
コード例 #37
0
ファイル: effort.py プロジェクト: joegillon/allocat
 def __load(self, months):
     employees = Employee.get_all()
     assignments = Assignment.get_for_timeframe(months[0], months[-1])
     employee_assignments = {}
     for assignment in assignments:
         if assignment['employee_id'] not in employee_assignments:
             employee_assignments[assignment['employee_id']] = []
         employee_assignments[assignment['employee_id']].append(assignment)
     for employee in employees:
         row = EffortRow(employee)
         for month in months:
             cell = EffortCell(month)
             if employee['id'] not in employee_assignments:
                 continue
             for emp_asn in employee_assignments[employee['id']]:
                 if int(month) < emp_asn['first_month'] or int(month) > emp_asn['last_month']:
                     continue
                 cell.total += emp_asn['effort']
                 cell.percent_efforts.append(
                     PercentEffort(emp_asn['project'], emp_asn['effort'])
                 )
             row.effort_cells.append(cell)
         if row.effort_cells:
             self.effort_rows.append(row)
コード例 #38
0
	def get(self, args=None):
		employee_id = self.request.get('employee_id')
		firstName = self.request.get('firstName')
		lastName = self.request.get('lastName')
		appointment = self.request.get('appointment')
		username = self.request.get('username')
		password = self.request.get('password')
		shiftHeadable = self.request.get('shiftHeadable')
		
		
		if not employee_id or not firstName or not lastName or not appointment or not username or not password:
			self.response.write("one or more fields are empty!")
			return
		
		employee = Employee.query(Employee.userName == username).get()
		
		if employee:
			self.response.write('This username already exist!')
			return
			
		employee = Employee()
		employee.workerID = employee_id
		employee.firstName = firstName
		employee.lastName = lastName
		employee.userName = username
		employee.setPassword(password)
		employee.percentJob = int(appointment)
		if shiftHeadable == 'true':
			employee.shiftHead = True
		elif shiftHeadable == 'false':		
			employee.shiftHead = False
	
			
		employee.isManager = False
		employee.put()
		
		self.response.write(json.dumps({'status':'OK'}))
コード例 #39
0
    def get(self):
		userName = None
		if self.request.cookies.get('our_token'):    #the cookie that should contain the access token!
			userName = Employee.checkToken(self.request.cookies.get('our_token'))

		today = date.today()
		today = today 
		today = today + timedelta(days = 14)
		if(int(today.strftime("%U"))%2 == 0):
			today = today - timedelta(days = 7)
		sunday0 = today
		monday0 = today
		tuesday0 = today
		wednesday0 = today
		thursday0 = today
		friday0 = today
		saturday0 = today
		
		if (today.weekday() == 6):
			sunday0 = today
			monday0 = sunday0 + timedelta(days=1)
			tuesday0 = monday0 + timedelta(days=1)
			wednesday0 = tuesday0 + timedelta(days = 1)
			thursday0 = wednesday0 + timedelta(days = 1)
			friday0 = thursday0 + timedelta(days = 1)
			saturday0 = friday0 + timedelta(days = 1)
			
		if (today.weekday() == 0):
			monday0 = today
			tuesday0 = monday0 + timedelta(days=1)
			wednesday0 = tuesday0 + timedelta(days = 1)
			thursday0 = wednesday0 + timedelta(days = 1)
			friday0 = thursday0 + timedelta(days = 1)
			saturday0 = friday0 + timedelta(days = 1)
			sunday0 = saturday0 - timedelta(days = 6)
			
		if (today.weekday() == 1):
			tuesday0 = today
			wednesday0 = tuesday0 + timedelta(days = 1)
			thursday0 = wednesday0 + timedelta(days = 1)
			friday0 = thursday0 + timedelta(days = 1)
			saturday0 = friday0 + timedelta(days = 1)
			sunday0 = saturday0 - timedelta(days = 6)
			monday0 = sunday0 + timedelta(days=1)
			
		if (today.weekday() == 2):
			wednesday0 = today
			thursday0 = wednesday0 + timedelta(days = 1)
			friday0 = thursday0 + timedelta(days = 1)
			saturday0 = friday0 + timedelta(days = 1)
			sunday0 = saturday0 - timedelta(days = 6)
			monday0 = sunday0 + timedelta(days=1)
			tuesday0 = monday0 + timedelta(days=1)
			
		if (today.weekday() == 3):
			thursday0 = today
			friday0 = thursday0 + timedelta(days = 1)
			saturday0 = friday0 + timedelta(days = 1)
			sunday0 = saturday0 - timedelta(days = 6)
			monday0 = sunday0 + timedelta(days=1)
			tuesday0 = monday0 + timedelta(days=1)
			wednesday0 = tuesday0 + timedelta(days = 1)
			
		if (today.weekday() == 4):
			friday0 = today
			saturday0 = friday0 + timedelta(days = 1)
			sunday0 = saturday0 - timedelta(days = 6)
			monday0 = sunday0 + timedelta(days=1)
			tuesday0 = monday0 + timedelta(days=1)
			wednesday0 = tuesday0 + timedelta(days = 1)
			thursday0 = wednesday0 + timedelta(days = 1)
			
		if (today.weekday() == 5):
			saturday0 = today
			sunday0 = saturday0 - timedelta(days = 6)
			monday0 = sunday0 + timedelta(days=1)
			tuesday0 = monday0 + timedelta(days=1)
			wednesday0 = tuesday0 + timedelta(days = 1)
			thursday0 = wednesday0 + timedelta(days = 1)
			friday0 = thursday0 + timedelta(days = 1)		
		
		if saturday0:
			sunday1 = saturday0 + timedelta(days=1)
			monday1 = saturday0 + timedelta(days=2)
			tuesday1 = saturday0 + timedelta(days=3)
			wednesday1 = saturday0 + timedelta(days=4)
			thursday1 = saturday0 + timedelta(days=5)
			friday1 = saturday0 + timedelta(days=6)
			saturday1 = saturday0 + timedelta(days=7)
		
		template_variables = {}
		if userName:
			template_variables['userName'] = userName.userName
			template_variables['sunday0'] = "%d/%d"%(sunday0.day ,sunday0.month)
			template_variables['monday0'] = "%d/%d"%(monday0.day ,monday0.month)
			template_variables['tuesday0'] = "%d/%d"%(tuesday0.day ,tuesday0.month)
			template_variables['wednesday0'] = "%d/%d"%(wednesday0.day ,wednesday0.month)
			template_variables['thursday0'] = "%d/%d"%(thursday0.day ,thursday0.month)
			template_variables['friday0'] = "%d/%d"%(friday0.day ,friday0.month)
			template_variables['saturday0'] = "%d/%d"%(saturday0.day ,saturday0.month)
			template_variables['sunday1'] = "%d/%d"%(sunday1.day ,sunday1.month)
			template_variables['monday1'] = "%d/%d"%(monday1.day ,monday1.month)
			template_variables['tuesday1'] = "%d/%d"%(tuesday1.day ,tuesday1.month)
			template_variables['wednesday1'] = "%d/%d"%(wednesday1.day ,wednesday1.month)
			template_variables['thursday1'] = "%d/%d"%(thursday1.day ,thursday1.month)
			template_variables['friday1'] = "%d/%d"%(friday1.day ,friday1.month)
			template_variables['saturday1'] = "%d/%d"%(saturday1.day ,saturday1.month)

			

			#### First week ####
			
			
			sunday0date = date(sunday0.year, sunday0.month, sunday0.day)
			
			# Sunday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Sunday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Sunday0NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Sunday0 morning info:	
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday0date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Sunday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Sunday0MorningAssignBeforeStandBy'] = assignBeforeStandBy

				
			# Sunday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Sunday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Sunday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			
			monday0date = date(monday0.year, monday0.month, monday0.day)	
			
				
			# Monday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Monday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Monday0NightAssignBeforeStandBy'] = assignBeforeStandBy
				
			# Monday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday0date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Monday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Monday0MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Monday0 noon info:		
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Monday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Monday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			

			tuesday0date = date(tuesday0.year, tuesday0.month, tuesday0.day)
			
				
			# Tuesday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Tuesday0NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Tuesday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday0date, 1, 1)
			assignBeforeThird = SubmittedShifts.checkIfAssignAlready(tuesday0date, 1, 2)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeThird:
				template_variables['Tuesday0MorningAssignBeforeThird'] = assignBeforeThird
				
			if assignBeforeStandBy:
				template_variables['Tuesday0MorningAssignBeforeStandBy'] = assignBeforeStandBy

			# Tuesday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Tuesday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			

			
			wednesday0date = date(wednesday0.year, wednesday0.month, wednesday0.day)
		
		
			# Wednesday0 night info:	
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday0NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Wednesday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday0date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday0MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Wednesday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			thursday0date = date(thursday0.year, thursday0.month, thursday0.day)
				
				
			# Thursday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Thursday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Thursday0NightAssignBeforeStandBy'] = assignBeforeStandBy
				
			# Thursday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday0date, 1, 1)
			assignBeforeThird = SubmittedShifts.checkIfAssignAlready(thursday0date, 1, 2)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Thursday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeSecond:
				template_variables['Thursday0MorningAssignBeforeThird'] = assignBeforeThird
				
			if assignBeforeStandBy:
				template_variables['Thursday0MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Thursday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Thursday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Thursday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			friday0date = date(friday0.year, friday0.month, friday0.day)
				
				
			# Friday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Friday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday0NighAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday0NighAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Friday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday0date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Friday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday0MorningAssignBeforeStandBy'] = assignBeforeStandBy

			# Friday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Friday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday0NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			saturday0date = date(saturday0.year, saturday0.month, saturday0.day)
				
				
			# Saturday0 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday0date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday0date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday0date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Saturday0NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday0NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday0NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Saturday0 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday0date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday0date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday0date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Saturday0MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday0MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday0MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Saturday0 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday0date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday0date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday0date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Saturday0NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday0NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday0NoonAssignBeforeStandBy'] = assignBeforeStandBy

				
			#### Second week ####
				

			sunday1date = date(sunday1.year, sunday1.month, sunday1.day)
				
			# Sunday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Sunday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday1NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Sunday1NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Sunday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday1date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Sunday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Sunday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
				
			# Sunday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(sunday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(sunday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(sunday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Sunday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Sunday1NoonAssignBeforeSecond'] = assignBeforeSecond
			
			

			monday1date = date(monday1.year, monday1.month, monday1.day)	
				
				
			# Monday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Monday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday1NightAssignBeforeSecond'] = assignBeforeSecond
			
			# Monday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday1date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Monday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Monday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Monday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(monday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(monday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(monday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Monday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Monday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Monday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			tuesday1date = date(tuesday1.year, tuesday1.month, tuesday1.day)
				
				
			# Tuesday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday1NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Tuesday1NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Tuesday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday1date, 1, 1)
			assignBeforeThird = SubmittedShifts.checkIfAssignAlready(tuesday1date, 1, 2)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeThird:
				template_variables['Tuesday1MorningAssignBeforeThird'] = assignBeforeThird
				
			if assignBeforeStandBy:
				template_variables['Tuesday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Tuesday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(tuesday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(tuesday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(tuesday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Tuesday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Tuesday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Tuesday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			wednesday1date = date(wednesday1.year, wednesday1.month, wednesday1.day)
			
			
			# Wednesday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday1NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday1NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Wednesday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday1date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Wednesday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(wednesday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(wednesday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(wednesday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Wednesday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Wednesday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Wednesday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			

			thursday1date = date(thursday1.year, thursday1.month, thursday1.day)
				
				
			# Thursday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Thursday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday1NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Thursday1NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Thursday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday1date, 1, 1)
			assignBeforeThird = SubmittedShifts.checkIfAssignAlready(thursday1date, 1, 2)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Thursday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeSecond:
				template_variables['Thursday1MorningAssignBeforeThird'] = assignBeforeThird
				
			if assignBeforeStandBy:
				template_variables['Thursday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Thursday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(thursday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(thursday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(thursday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Thursday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Thursday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Thursday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			

			friday1date = date(friday1.year, friday1.month, friday1.day)
				
				
			# Friday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Friday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday1NighAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday1NighAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Friday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday1date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Friday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Friday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(friday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(friday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(friday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Friday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Friday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Friday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
			
			saturday1date = date(saturday1.year, saturday1.month, saturday1.day)	
				
				
			# Saturday1 night info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday1date, 0, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday1date, 0, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday1date, 0, 3)
			
			if assignBeforeHead:
				template_variables['Saturday1NightAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday1NightAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday1NightAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Saturday1 morning info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday1date, 1, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday1date, 1, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday1date, 1, 3)
			
			if assignBeforeHead:
				template_variables['Saturday1MorningAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday1MorningAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday1MorningAssignBeforeStandBy'] = assignBeforeStandBy
			
			# Saturday1 noon info:
			assignBeforeHead = SubmittedShifts.checkIfAssignAlready(saturday1date, 2, 0)
			assignBeforeSecond = SubmittedShifts.checkIfAssignAlready(saturday1date, 2, 1)
			assignBeforeStandBy = SubmittedShifts.checkIfAssignAlready(saturday1date, 2, 3)
			
			if assignBeforeHead:
				template_variables['Saturday1NoonAssignBeforeHead'] = assignBeforeHead
				
			if assignBeforeSecond:
				template_variables['Saturday1NoonAssignBeforeSecond'] = assignBeforeSecond
				
			if assignBeforeStandBy:
				template_variables['Saturday1NoonAssignBeforeStandBy'] = assignBeforeStandBy
			
			
		html = template.render("web/templates/NextSchedule.html", template_variables)
		self.response.write(html)
			
		if not userName:
			html = template.render("web/templates/LoginPage.html", template_variables)
			self.response.write(html)