def pub_index_publish():
    """
    首页,重定向到当前月份
    :return:
    """
    # print("用户状态*************", current_user, current_user.is_active, current_user.is_authenticated,
    #       current_user.is_anonymous)
    emsg = None
    log_message = str({"rout_url": "pub_calendar.pub_index_publish", "result": "success", "emsg": emsg,
                       "user_ip": request.remote_addr})
    app.logger.info(log_message)
    return redirect("/pub/show_calendar/{}".format(AboutTime().get_today_year_month()))
Esempio n. 2
0
def user_index(username):
    """首页,重定向到当前月份"""
    # print("user_index --- 用户状态*************", current_user, current_user.is_active, current_user.is_authenticated,
    #       current_user.is_anonymous)
    emsg = None
    log_message = str({
        "rout_url": "user_calendar.user_index",
        "result": "success",
        "emsg": emsg,
        "username": current_user.username,
        "user_ip": request.remote_addr
    })
    app.logger.info(log_message)
    return redirect("/{}/show_calendar/{}".format(
        username,
        AboutTime().get_today_year_month()))
Esempio n. 3
0
 def pub_get_this_month_notes(self, year_month):
     """根据日历展示  获取指定月份是否包含记录"""
     year, month = str(year_month).split("-")
     days_list, year, month = AboutTime().get_calendar_show(year=year,
                                                            month=month)
     # print(days_list)
     # 将本月所有天数设置为无记录状态
     for day in days_list:
         day['is_note_day'] = False
     # 指定天数有记录时,设置为true
     for calendar_day in days_list:
         d = self.pub_get_today_notes(year=calendar_day['year'],
                                      month=calendar_day['month'],
                                      day=calendar_day['day'])
         if d:
             calendar_day['is_note_day'] = True
     return days_list, year, month
Esempio n. 4
0
 def pub_update_note(self, noteid, new_note, update_ip):
     """更新记录"""
     new_note = new_note.replace(" ", "")  # 如果new_note为一个空格时,替换空格删除数据
     if new_note:  # 替换空格后还有非空字段就更新数据
         # 先查询指定id的记录,查询结果为一条数据对象
         old_note_info = self.pubnote.query.filter(
             self.pubnote.id == noteid).first()
         # 将数据对象的note值换为新的值
         old_note_info.note = new_note
         # 更新时间和ip
         old_note_info.update_time = AboutTime().get_now_time()
         old_note_info.update_ip = update_ip
     else:  # 删除数据
         note_info = self.pubnote.query.filter(
             self.pubnote.id == noteid).first()
         db.session.delete(note_info)
     # 提交修改
     self.db.session.commit()
def pub_show_calendar(today_year_month):
    """
    根据不同年月展示指定月份
    :param today_year_month: 指定的年月 格式:year-month
    :return:
    """
    emsg = None
    now_year, now_month, now_day = AboutTime().get_today_year_month_day()
    today_date = str(now_year) + "-" + str(now_month) + "-"  # 年份月份格式
    year_selections = [year for year in range(now_year - 1, now_year + 2)]  # 年份下拉框
    month_selections = [month for month in range(1, 13)]  # 月份下拉框
    # 返回当月
    if today_year_month == str(now_year) + "-" + str(now_month):
        days_list, now_year, now_month = NotesManage().pub_get_this_month_notes(year_month=today_year_month)
        log_message = str({"rout_url": "pub_calendar.pub_show_calendar",
                           "result": "/pub/show_calendar/{}, 当月日历显示".format(today_year_month), "emsg": str({
                "days_list": days_list, "now_year": now_year, "now_month": now_month, "today_date": today_date,
                "year_selections": year_selections, "month_selections": month_selections}),
                           "today_year_month": today_year_month, "user_ip": request.remote_addr})
        app.logger.info(log_message)
        return render_template("calendar/calendar_pub_show_calendar.html", days_list=days_list, today_date=today_date,
                               today=now_day,
                               show_today=now_day, year_selections=year_selections, show_year_month=today_date,
                               month_selections=month_selections)
    else:  # 指定年月
        select_year, select_month = int(today_year_month.split("-")[0]), int(today_year_month.split("-")[1])
        show_year_month = today_year_month + "-"
        show_today = 0  # 展示今天特殊标记
        if select_year == now_year and select_month == now_month:
            show_today = now_day
        days_list, year, month = NotesManage().pub_get_this_month_notes(year_month=today_year_month)
        log_message = str({"rout_url": "pub_calendar.pub_show_calendar",
                           "result": "/pub/show_calendar/{}, 指定年月日历显示".format(today_year_month), "emsg": str({
                "days_list": days_list, "now_year": now_year, "now_month": now_month, "today_date": today_date,
                "year_selections": year_selections, "month_selections": month_selections}),
                           "today_year_month": today_year_month, "show_today": show_today,
                           "user_ip": request.remote_addr})
        app.logger.info(log_message)
        return render_template("calendar/calendar_pub_show_calendar.html", days_list=days_list, today_date=today_date,
                               today=now_day,
                               show_today=show_today, year_selections=year_selections, show_year_month=show_year_month,
                               month_selections=month_selections)