会议室预定demo

关于会议室的增删改查

查:

HTML:

login继承django自带的admin用户认证系统

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="" method="post">
    {% csrf_token %}
    <p>姓名 <input type="text" name="user"></p>
    <p>密码 <input type="password" name="pwd"></p>
    <input type="submit">
</form>

</body>
</html>

login

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/static/bootstrap-3.3.7/css/bootstrap.css">
    <script src="/static/jquery-3.2.1.min.js"></script>

    <title>会议室</title>
    <style >
    .active {
        background-color: deepskyblue !important;
        color: black;
        text-align: center;
        font-size: 16px;
    }

    .td_active {
        background-color: greenyellow ;
    }

    .active_other {
        background-color: orange !important;
        color: white;
        text-align: center;
        font-size: 16px;
    }

</style>
</head>

<body>
<div class="container">
    <div class="row">
        <div class="col-md-11">
            <h3>会议室预定</h3>

            <div>
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>会议室</th>
                        {#  时间 时间元组 #}
                        {% for item in time_choices %}
                            <th>{{ item.1 }}</th>
                        {% endfor %}
                    </tr>
                </thead>
                    <tbody>
                        {{ html|safe }}
                    </tbody>

                </table>
                <button class="btn btn-primary pull-right keep">保存</button>
            </div>

        </div>
    </div>
</div>
<script>

</script>
</body>
</html>

index.

PY:

from django.db import models

# Create your models here.
from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.
class MeetingRoom(models.Model):
    ‘‘‘会议室 ‘‘‘
    name = models.CharField(max_length=32,verbose_name="会议室名称")
    num = models.IntegerField()     # 最大开会人数

    def __str__(self):
        return self.name

class UserInfo(AbstractUser):
    tel=models.CharField(max_length=32)

    def __str__(self):
        return self.username

class Book(models.Model):
    ‘‘‘预定记录表‘‘‘
    date = models.DateField(verbose_name="预定日期")
    user = models.ForeignKey(to="UserInfo",verbose_name="预订用户")         # 关联用户
    room = models.ForeignKey(to="MeetingRoom",verbose_name="预定房间")      # 关联房间
    time1 = (
        (1,"8.00"),
        (2,"9.00"),
        (3,"10.00"),
        (4,"11.00"),
        (5,"12.00"),
        (6,"13.00"),
        (7,"14.00"),
        (8,"15.00"),
        (9,"16.00"),
        (10,"17.00"),
        (11,"18.00"),
        (12,"19.00"),
        (13,"20.00"),
    )
    timeline = models.IntegerField(choices=time1,verbose_name="预定时间")    # 存的是数字

    class Meta:
        # 联合唯一,为什么没有user,因为只有有下面3个字段,即表示有预定了
        unique_together = (
            (‘room‘,‘date‘,‘timeline‘),
        )

    def __str__(self):
        return str(self.user) + "预定了" + str(self.room)

model

from django.shortcuts import render,redirect

# Create your views here.
from .models import *

def index(request):
    #   取到所有的预定信息
    book_list = Book.objects.all()
    #   取所有的房间信息
    room_list = MeetingRoom.objects.all()
    #   房间的时间段
    time_choices = Book.time1

    # 渲染空的td, 有几个td,取决于有几个时间段
    html=""
    for room in room_list:
        s = "<tr><td>{0}({1})</td>".format(room.name,room.num)
        for item in time_choices:  #  循环所有的时间段单元格 ((1,"8:00"))()
            flag=False      # 标志有否预定信息
            for book in book_list:      # 循环每个预定信息
                print(MeetingRoom.pk)
                if book.room.pk == room.pk and book.timeline == item[0]:

                    flag=True # 通过
                    break
            if flag:
                # 最后循环出来的book是匹配的信息
                if request.user.pk != book.user.pk:  # 不同用户显示不同的样式
                    s += ‘<td class="active_other item" room_id="{0}" time_id="{1}">{2}</td>‘.format(room.pk,item[0],book.user.username)
                else:
                    s += ‘<td class="active item" room_id="{0}" time_id="{1}">{2}</td>‘.format(room.pk,item[0],book.user.username)
            else:
                s += ‘<td class="item" room_id="{0}" time_id="{1}"></td>‘.format(room.pk,item[0])
        s += "</tr>"
        html += s
    return render(request,"index.html",locals())

from django.contrib import auth

def login(request):
    if request.method == "POST":
        user = request.POST.get("user")
        pwd = request.POST.get("pwd")
        user = auth.authenticate(username=user, password=pwd)
        if user:
            auth.login(request, user)   # 注册session
            return redirect("/index/")

    return render(request, "login.html")

views

关于DATE--转化-->年月日

也可以通过CHOSEN_DATE=new Date().getFullYear()等等,各取出年月日,拼成年月日

知识点:js

自定义标签方法

-------------

datetime.date---->年月日

datetime.time----->时分秒

datetime.datetime---->年月日时分秒

BUG1

使用时间插件跳转某日期,由于ajax,刷新页面导致date重新赋值 一直是当前日期。

思路:直接取url的值http://127.0.0.1:8000/index/?book_date=2018-03-29

原文地址:https://www.cnblogs.com/jassin-du/p/8667269.html

时间: 2024-08-01 04:56:33

会议室预定demo的相关文章

启明星会议室预定系统更新日志-通用版

启明星会议室预定系统更新日志 V9.1更新说明 1.解决资源释放bug. bug说明:用户预定了“投影仪",在更新预定时,如果在投影仪选项里,直接删除了”投影仪“文字,这意味着用户不使用投影仪.更新成功,应该释放投影仪占用的资源.       但是目前更新成功后,该资源仍被占用,不会释放 2.增加了周查询功能,以及快速预定 V9.0更新说明 从9.0开始,启明星系统采用全新的构架,并且不在兼容早期的版本.而且,V9不再支持IE6与IE7. 除了界面上变更,V9对预定系统进行了简化.主要功能说明如

会议室预定终章

1. 会议室预定功能简介 用户登陆系统,可以预定会议室,退订,不可对其他用户预定的会议室预定 2. 会议室知识点扩充 2.1 加载框 加载框的含义是,每次数据提交会有一些效果,比如转圈等 本质利用了遮罩层 {# 模态对话框形式的加载框#} .hide{ display: none; } .shade { position: fixed; z-index: 1040; top: 0; left: 0; right: 0; bottom: 0; background-color: #999; fil

会议室预定(可作为插件使用)

会议室预定(小项目) 该项目仍旧是用Django框架完成的,此项目的重点在于前端页面中有关预定的操作 首先建表,这里用的表较少,一共三张表,表结构如下: from django.db import models class UserInfo(models.Model): name = models.CharField(verbose_name='用户姓名', max_length=32) password = models.CharField(verbose_name='密码', max_len

启明星会议室系统与Office365集成说明

在本文,我们将介绍如何配置Office365,以便改系统能够支持启明星会议室预定系统. In this article, we will introduct how to config microsoft office365 to enable it to support dotnetcms.org book system. 1.以管理员的身份登陆office365. 1.login into office365 with administrator role. 2.当登陆成功后,可以在右上角的

如何通过组策略禁用outlook exchange add-in,控制会议室管理工具

需求源:公司开始会议室预定全部依靠outlook,会议室查找工具(outlook room finder)非常高效的解决了会议室冲突的问题.但是OA系统上线后,又不想大家从outlook预定会议室了,因为OA页面把公司三地会议室放在一个页面了,一目了然,相比outlook更加便捷. 为了推广OA并"强制"把数据源推广到OA,需要暂时把outlook的会议室查找工具禁用. 问题:公司100多人,如何批量完成此操作? 思路及方法:借助域控组策略,但是具体怎么实施? 经查找,控制outloo

php 会议预定系统

最近这段时间,在用php做一个会议室预定系统,由于刚开始接触php语言,所以对于语法不是很熟悉,在这个学习和制作项目的过程中,发现了一些问题,借着今天周末的时间,总结一下,希望能对像我这样的菜鸟,有所帮助,如果发现bug或者有争议的地方,欢迎指出,沟通互动与交流,谢谢. 我使用的是yaf框架,ngnix服务器,mysql数据库,php5.5.关于系统的安装,请参考上一篇帖子,地址如下:http://mig1924615.blog.51cto.com/9385857/1755532 刚开始觉得,用

微信小程序源码下载(200多个)

微信小程序源码下载汇总,点击标题进入对应的微信小程序下载页面. 最新 demo源码(点击标题进入帖子下载) 描述 1 微信小程序 会议室预定小程序 微信小程序 会议室预定小程序**** 本内容被作者隐藏 **** 2 微信小程序-双人五子棋小游戏 微信小程序-双人五子棋小游戏**** 本内容被作者隐藏 **** 3 打卡签到小程序 用微信小程序实现的一个简单的打卡签到的小程序拒绝 4 微信小程序---左滑删除 微信小程序---左滑删除**** 本内容被作者隐藏 **** 5 一个借钱的记事本的微

伴随着我娃成长的运维平台(持续开源..)

写在片头:我娃出生的时候,平台V1.0版本正好上线.纯属个人项目,身兼业务需求人员,产品经理,前端,后端,测试于一体,代码层面会有逻辑问题,请各位看官见谅. 很多人都问我为什么不直接上代码,写那么多废话干啥.我只想说,冰冷的代码无法表达我对运维的热爱,我会以授之以渔的方法去介绍我当时写各个模块的思路,让在运维路上的兄弟少走一些弯路.在各个模块全部介绍完毕的时候会将源码放到Github上,每天力求一次更新. 在这里你不但可以了解我的思路,也能了解我在前端.后端踩过的一些坑~别问我是谁,叫我红领巾.

张左峰的歪理邪说 之 Redmine 1.4.X 史上最全插件方案

前面有一个0.9.X的插件推荐列表,但是太老了,更新一下! PS.很多插件是我自己汉化,甚至付费的,并且进行小幅修改,所以仅供参考..... PPS.话说,搞Redmine这帮人,真是一群疯子,更新太快了.....就不敢更新慢点么...... Advanced roadmap & milestones plugin  0.7.0  高级路线图,里程碑,不解释Author box  0.0.3  这个可以在Wiki侧边栏显示一个你的头像和信息,搞个人崇拜用的CRM plugin 2.3.3-pro