Esempio n. 1
0
def user_save():
    """ユーザー情報詳細画面登録処理

    formのデータをDBに保存します。
    処理終了後はマスタユーザー一覧画面へ遷移します。
    """
    groupIdList = getComItemList('group_id')
    form = UserForm()
    form.groupId.choices = [(i.item_cd, i.item_value) for i in groupIdList]
    if form.validate_on_submit():
        data = form.data
        data['password'] = bcrypt.generate_password_hash(
            form.password.data).decode(encoding='utf-8')
        isUpdate = False
        dto = getComUser(data['userId'])
        if dto:
            isUpdate = True
        insertUpdateComUser(data, isUpdate)
        if isUpdate:
            flash(Messages.SUCCESS_UPDATED, Messages.SUCCESS_CSS)
        else:
            flash(Messages.SUCCESS_INSERTED, Messages.SUCCESS_CSS)
        return redirect(url_for('userManagement.user_list'))
    for error in form.errors.values():
        flash(error[0], Messages.DANGER_CSS)
    cont = detailsCont(form)
    return render_template('user_management/user-details.html', cont=cont)
Esempio n. 2
0
def monthly_report_calendar():
    """月報カレンダーの一覧表示  Getのrequestを受付
    ナビバーからのrequsetはディフォルトで当月を表示します。
    当処理はhtmlテンプレート及び画面用コンテンツを返します。

    :param month: 該当月のデータ取得用「月」
    :param u:管理者の場合、選択されたユーザのID
    """
    month = request.args.get('month', default=date.today().month, type=int)
    userId = request.args.get('u', type=str)
    if not userId:
        userId = session.get('mr_pick_user')
        if userId == 'undefined' or userId == None:
            userId = current_user.user_id

    if current_user.role == 2:
        pick_user = getComUser(userId)
        if not pick_user or pick_user.group_id != current_user.group_id:
            return redirect(
                url_for('monthlyReport.monthly_report_calendar', month=month))
        cont = calendarCont(month)
        cont.userId = pick_user.user_id
        cont.userName = pick_user.user_name
        cont.userList = getUserList(current_user.group_id)
    else:
        cont = calendarCont(month)

    cont.calendaDetails = createCalendarList(userId, month,
                                             Category.CATEGORY_MONTHLY_REPORT)
    cont.monthList = getNumberList(1, 13, 1)
    session['mr_pick_user'] = userId
    return render_template('monthly_report/monthly-report-calendar.html',
                           cont=cont)
Esempio n. 3
0
def user_edit(userId):
    """ユーザー修正処理

    一覧画面から「月日」を押下後、GETのrequestを受付します。
    htmlテンプレート及び画面用コンテンツを返します。

    :param userId: 修正対象データのID
    """
    dto = getComUser(userId)
    if not dto:
        flash(Messages.WARNING_NOT_FOUND_ALREADY_UPDATED_DELETED,
              Messages.WARNING_CSS)
        return redirect(url_for('userManagement.user_list'))

    groupIdList = getComItemList('group_id')
    form = UserForm()
    form.groupId.choices = [(i.item_cd, i.item_value) for i in groupIdList]

    form.userId.data = dto.user_id
    form.userName.data = dto.user_name
    form.groupId.data = dto.group_id
    form.role.data = dto.role
    form.email.data = dto.email

    cont = detailsCont(form)
    return render_template('user_management/user-details.html', cont=cont)
Esempio n. 4
0
    def edit_file(self, userId, data):
        """帳票書き込み処理

        :param userId: 出力対象ユーザID
        :param models: 出力詳細データ格納model
        """
        try:
            if data['models']:
                dto = getComUser(userId)
                sheet = self.book.active

                # ヘッダ項目:年・月・作業者名
                sheet.cell(1, 1).value = data['year'] + '年'
                sheet.cell(1, 3).value = data['month'] + '月分 作業報告書'
                sheet.cell(1, 11).value = dto.user_name

                # フッター項目:出勤日数

                # 詳細データ
                row = 9
                column = 1
                for model in data['models']:
                    if model.rest_flg == 1:
                        sheet.cell(
                            row,
                            column).value = str(model.work_year) + '/' + str(
                                model.work_month) + '/' + str(model.work_day)
                        sheet.cell(row, column + 2).value = '休み'
                        row += 1
                    else:
                        sheet.cell(
                            row,
                            column).value = str(model.work_year) + '/' + str(
                                model.work_month) + '/' + str(model.work_day)
                        sheet.cell(row, column + 2).value = model.work_details
                        sheet.cell(row,
                                   column + 5).value = model.start_work_time
                        sheet.cell(row, column + 6).value = model.end_work_time
                        sheet.cell(row, column +
                                   7).value = model.normal_working_hours
                        sheet.cell(row,
                                   column + 8).value = model.overtime_hours
                        sheet.cell(row,
                                   column + 9).value = model.holiday_work_hours
                        row += 1

                self.book.save(self.tmp_file)
                result_file = open(self.tmp_file, "rb").read()
            else:
                result_file = None
        except TypeError:
            # 変なデータが登録されない限り、TypeErrorは起こらないが、念のため
            traceback.print_exc()
        super().close_file()

        return result_file
Esempio n. 5
0
def user_mypage():
    """マイアカウントページ処理

    画面から「自分のユーザ名」を押下後、GETのrequestを受付します。
    htmlテンプレート及び画面用コンテンツを返します。
    """
    dto = getComUser(current_user.user_id)
    form = MyPageForm()
    form.userName.data = dto.user_name
    form.email.data = dto.email
    cont = detailsCont(form)
    return render_template('user_management/mypage.html', cont=cont)
Esempio n. 6
0
    def edit_file(self, userId, models):
        """帳票書き込み処理

        :param userId: 出力対象ユーザID
        :param models: 出力詳細データ格納model
        """
        try:
            if models:
                dto = getComUser(userId)
                sheet = self.book.active
                # 氏名
                sheet.cell(6, 9).value = dto.user_name
                # 期間及び提出日
                __, lastDay = monthrange(models[0].entry_year,
                                         models[0].entry_month)
                sheet.cell(8, 2).value = str(models[0].entry_year) + '年' + str(
                    models[0].entry_month) + '月' + '1日'
                sheet.cell(8, 5).value = str(models[0].entry_year) + '年' + str(
                    models[0].entry_month) + '月' + str(lastDay) + '日'
                sheet.cell(8, 9).value = str(models[0].entry_year) + '年' + str(
                    models[0].entry_month) + '月' + str(lastDay) + '日'
                row = 12
                column = 1
                for model in models:
                    sheet.cell(row, column).value = model.expense_date
                    sheet.cell(row, column + 1).value = model.expense_item
                    sheet.cell(row, column + 2).value = model.route
                    sheet.cell(row, column + 4).value = model.transit
                    sheet.cell(row, column + 5).value = model.payment
                    sheet.cell(row, column + 6).value = ''
                    sheet.cell(row, column + 7).value = model.file_name
                    sheet.cell(row, column + 8).value = model.note
                    row += 1
                self.book.save(self.tmp_file)
                result_file = open(self.tmp_file, "rb").read()
            else:
                result_file = None
        except TypeError:
            # 変なデータが登録されない限り、TypeErrorは起こらないが、念のため
            traceback.print_exc()
        super().close_file()

        return result_file
Esempio n. 7
0
def user_mypage_save():
    """マイアカウント登録処理

    変更後の情報を保存します。
    """
    dto = getComUser(current_user.user_id)
    form = MyPageForm()
    if form.validate_on_submit():
        data = form.data
        data['password'] = bcrypt.generate_password_hash(
            form.password.data).decode(encoding='utf-8')
        data['userId'] = current_user.user_id
        data['groupId'] = current_user.group_id
        data['role'] = dto.role
        insertUpdateComUser(data, True)
        flash(Messages.SUCCESS_UPDATED, Messages.SUCCESS_CSS)
        return redirect(url_for('home.index'))
    else:
        for error in form.errors.values():
            flash(error[0], Messages.DANGER_CSS)
    cont = detailsCont(form)
    return render_template('user_management/mypage.html', cont=cont)