コード例 #1
0
ファイル: site_actions.py プロジェクト: Boomatang/ProjectF
    def get_assigned_jobs(self):

        """
        Gets any jobs that may have been assigned to the user
        :return: returns a list if true else None
        """
        output = None
        sql = u'SELECT job_ID_year, job_ID_number ' \
              u'FROM member_linked_jobs_TBL ' \
              u'WHERE person_ID = %s'

        data = (self.id,)

        if verify_user_company_schema(self.login_details):
            c, conn = connection(self.login_details['company_schema'])

            try:
                c.execute(sql, data)
                values = c.fetchall()

                if values is not None:
                    output = values
            finally:
                conn_close(c, conn)

        return output
コード例 #2
0
ファイル: site_actions.py プロジェクト: Boomatang/ProjectF
    def get_default_email(self):
        """
        Function gets the default email address for the user
        :return: an email address
        """
        email = '*****@*****.**'
        sql = u'SELECT detail ' \
              u'FROM communication_TBL ' \
              u'WHERE person_ID = %s ' \
              u'AND main = 1 ' \
              u'AND communication_type = "email"'
        data = (self.login_details['person_ID'])

        if verify_user_company_schema(self.login_details):
            c, conn = connection(self.login_details['company_schema'])

            try:
                c.execute(sql, data)
                value = c.fetchone()

                if value is not None:
                    email = value[0]
            finally:
                conn_close(c, conn)
        return email
コード例 #3
0
ファイル: fayino.py プロジェクト: Boomatang/ProjectF
def private_home():
    user = User(session["login_details"], session["login_details"]["person_ID"])

    assigned_jobs = []
    if user.assigned_jobs is not None:

        for job_number in user.assigned_jobs:
            job = Job(job_number, session["login_details"], user.id)
            assigned_jobs.append(job)

    form = Form(request.form)
    if request.method == "POST" and assigned_jobs is not None:
        if sql_functions.verify_user_company_schema(session["login_details"]):

            for jobs in assigned_jobs:
                if jobs.job_number in request.form:

                    if request.form[jobs.job_number] == "Start":
                        start_time = jobs.start_time_entry(user.id)
                        flash(start_time.strftime("%Y/%m/%d %H:%M"))

                    elif request.form[jobs.job_number] == "Stop":
                        finish_time = jobs.user_stop_log(user.id)
                        flash(finish_time.strftime("%Y/%m/%d %H:%M"))

    return render_template("private/index.html", user=user, assigned_jobs=assigned_jobs, form=form)
コード例 #4
0
ファイル: fayino.py プロジェクト: Boomatang/ProjectF
def user_details(person_ID):
    """
    Bring the overview of all the details to show
    :param job_number:
    :return:
    """
    login_details = session["login_details"]

    user = User(login_details, person_ID)
    # jobs assigned to the user
    assigned_jobs = []
    if user.assigned_jobs is not None:

        for job_number in user.assigned_jobs:
            job = Job(job_number, session["login_details"], user.id)
            assigned_jobs.append(job)

    # jobs that the user has worked on
    job_list = []
    if user.jobs_list is not None:
        for list_entry in user.jobs_list:
            job_entry = Job(list_entry, login_details)
            job_list.append((job_entry.job_number, job_entry.title, job_entry.get_times(user.id)))

    # page function
    form = Form(request.form)
    if request.method == "POST" and assigned_jobs is not None:
        if sql_functions.verify_user_company_schema(session["login_details"]):

            for jobs in assigned_jobs:
                if jobs.job_number in request.form:

                    if request.form[jobs.job_number] == "Start":
                        start_time = jobs.start_time_entry(user.id)
                        flash(start_time.strftime("%Y/%m/%d %H:%M"))

                    elif request.form[jobs.job_number] == "Stop":
                        finish_time = jobs.user_stop_log(user.id)
                        flash(finish_time.strftime("%Y/%m/%d %H:%M"))

    return render_template(
        "private/users/main_details.html", user=user, assigned_jobs=assigned_jobs, job_list=job_list, form=form
    )
コード例 #5
0
ファイル: fayino.py プロジェクト: Boomatang/ProjectF
def confirm_user_setup_details():
    # Setup company schema for user
    # Add the user to the company schema

    if sql_functions.verify_user_company_schema(session["login_details"]):
        # create the required tables for the schema
        # Setup company schema for user
        company_schema = session["login_details"]["company_schema"]
        sql_functions.create_company_schema(company_schema)
        sql_functions.create_company_schema_tables(company_schema)

        # Add the user to the company schema
        person_ID = sql_functions.add_user_to_company_member_tbl(
            session["login_details"], session["temp_user_details"][1]
        )

        session["login_details"]["person_ID"] = person_ID

    user = User(session["login_details"])

    return render_template("SetUp/confirmDetails.html", user=user)
コード例 #6
0
ファイル: site_actions.py プロジェクト: Boomatang/ProjectF
    def jobs_worked_on(self):
        """
        This returns a list of all the jobs a user has worked on
        :return:
        """
        output = None
        sql = u'SELECT DISTINCT job_ID_year, job_ID_number ' \
              u'FROM job_time_log_TBL ' \
              u'WHERE person_ID = %s'

        if verify_user_company_schema(self.login_details):
            c, conn = connection(self.login_details['company_schema'])

            try:
                c.execute(sql, self.id)
                value = c.fetchall()

                if value is not None:
                    output = value
            finally:
                conn_close(c, conn)

            return output
コード例 #7
0
ファイル: site_actions.py プロジェクト: Boomatang/ProjectF
    def job_times(self, job_id=None):

        """
        returns the time that has been spent on all jobs or just the one.
        :param job_id:
        """
        # TODO add in the function to check between dates
        time = 0
        if job_id is not None:
            sql = u'SELECT SUM(total_time) ' \
                  u'FROM job_time_log_TBL ' \
                  u'WHERE person_ID = %s ' \
                  u'AND job_ID_year = %s ' \
                  u'AND job_ID_number = %s '

            data = (self.id, job_id[0], job_id[1])

        else:

            sql = u'SELECT SUM(total_time) ' \
                  u'FROM job_time_log_TBL ' \
                  u'WHERE person_ID = %s'
            data = (self.id,)

        if verify_user_company_schema(self.login_details):
            c, conn = connection(self.login_details['company_schema'])

            try:
                c.execute(sql, data)
                value = c.fetchone()

                if value is not None:
                    time = value[0]
            finally:
                conn_close(c, conn)

            return time
コード例 #8
0
ファイル: fayino.py プロジェクト: Boomatang/ProjectF
def job_main_details(job_number):
    """
    Bring the overview of all the details to show
    :param job_number:
    :return:
    """
    # TODO a lot of this code maybe able to be put in the Job Class

    login_details = session["login_details"]
    # Job details
    year, number = job_number.split("-")

    job_number_sql = (int(year), int(number))

    job = Job(job_number_sql, login_details)
    client_company_list = []
    client_company_id_list = []
    # assigned users
    member_list = []
    id_list = sql_functions.job_assigned_users(login_details, job_number_sql)
    if id_list is not None:
        for id_value in id_list:
            member_list.append(User(login_details, id_value))
    else:
        member_list = None

    # User list
    user_list = []
    number_list = sql_functions.get_all_user_ids(login_details)

    for number in number_list:
        if number in id_list:
            pass
        else:
            user_list.append(User(login_details, number))

    # user that have put time to the job
    time_users = []
    if job.timed_user_ids:
        for user_with_time in job.timed_user_ids:
            user_time = User(login_details, user_with_time)
            time_users.append((user_time.id, user_time.username, user_time.job_times(job.job_number_sql)))

    # get the list of companies so that one can be added to the job.
    if job.company_assigned:
        pass
    else:
        company_id_list = site_actions.ClientCompany.all_companies(login_details["company_schema"])

        for company in company_id_list:
            client_company = site_actions.ClientCompany(company, login_details)
            client_company_list.append(client_company)
            client_company_id_list.append(company[0])

    # page form details
    form = Form(request.form)
    if request.method == "POST":
        if sql_functions.verify_user_company_schema(login_details):
            user = session["login_details"]["person_ID"]

            if request.form["timer"] == "Start":
                start_time = job.start_time_entry(user)
                flash(start_time.strftime("%Y/%m/%d %H:%M"))

            elif request.form["timer"] == "Stop":
                finish_time = job.user_stop_log(user)
                flash(finish_time.strftime("%Y/%m/%d %H:%M"))

            elif request.form["timer"] == "Assign":
                user_assigned = []

                for value in request.form:
                    for user in user_list:
                        if value == "user" + str(user.id):
                            user_assigned.append(user.id)

                for user_id in user_assigned:
                    values = (job_number_sql[0], job_number_sql[1], user_id)

                    sql_functions.assign_users_to_job(values, login_details)

            elif request.form["timer"] == "Remove Members" and member_list is not None:
                remove_member = []
                for value in request.form:
                    for member in member_list:
                        if value == "member" + str(member.id):
                            remove_member.append(member.id)

                for member_id in remove_member:
                    values = (job_number_sql[0], job_number_sql[1], member_id)
                    sql_functions.remove_users_from_job(values, login_details)

            elif request.form["timer"] == "Assign company" and client_company_list is not None:
                for value in request.form:
                    for client_id in client_company_id_list:
                        try:
                            if int(value) == client_id:
                                job.add_client_company(int(value))
                                flash(value)
                        except ValueError:
                            pass

        return redirect(url_for("job_main_details", job_number=job.job_number))
    current_user = User(session["login_details"])

    return render_template(
        "private/jobs/main_details.html",
        job=job,
        user_list=user_list,
        member_list=member_list,
        time_users=time_users,
        current_user=current_user,
        client_company_list=client_company_list,
        form=form,
    )