Commits

reorx committed a873498

finish modify department/, now the duty/

  • Participants
  • Parent commits cc9e15d

Comments (0)

Files changed (17)

department/getdb.py

         status = 'success'
     return status
 
-def delete(name):
-    Department.objects.get(name=name).delete()
+def delete(id):
+    Department.objects.get(id=id).delete()
     status = 'delete'
     return status
-def change(name,to):
-    d = Department.objects.get(name=name)
+
+def change(id,to):
+    d = Department.objects.get(id=id)
     d.name = to
     d.save()
     status = 'change'

department/getdb.pyc

Binary file modified.

department/views.py

 
 @permission_required('duty.can_change')
 def delete(request):
-    name = request.GET.get('name')
-    status = getdb_dpmt.delete(name)
+    id = request.GET.get('id')
+    status = getdb_dpmt.delete(id)
     return HttpResponse(status)
 
 @permission_required('duty.can_change')
 def change(request):
-    name = request.GET.get('name')
+    id = request.GET.get('id')
     to = request.GET.get('to')
-    status = getdb_dpmt.change(name,to)
+    status = getdb_dpmt.change(id,to)
     return HttpResponse(status)

department/views.pyc

Binary file modified.
         )
     else:
         member_come = getdb_duty.get_come_today()
-        condition = Dateinfo.objects.get(date=date_today)
-        condition = '今天是 ' + str(condition.date)
+        status = Dateinfo.objects.get(date=date_today)
+        status = '今天是 ' + str(status.date)
         #user = request.user #instead context_instance
         return render_to_response('home/home.html',{
             #'user' : user,
             'member_come_list' : member_come,
-            'condition' : condition,
+            'status' : status,
             },
             context_instance=RequestContext(request)
         )

home/views.pyc

Binary file modified.

static/css/base.css

-/*button*/
-.bigButton {
-    display: block;
-    border: 1px solid #7bc30a;
-    border-radius: 8;
-    padding: 4 0 4 0;
-    text-align: center;
-    width: 80px;margin: 0 auto;
-    background: white;color: #7bc30a;
-    font-size: 22px;
-}
-.bigButton:hover {
-    background: #7bc30a;color: white;
-    cursor: hand;
-}
-
 /*general*/
 body {
     margin: 0;
     background: -webkit-gradient(linear, left top, left bottom, from(#51c8df), to(#fff));
     background: -moz-linear-gradient(top,  #51c8df,  #fff);
 }
-a {
-    text-decoration: none;
-}
-a:visited { color: #0388ff}
-img {
-    width: 100px;height: 100px;
-}
 
-ul {
-    margin: 0;padding: 0;
-}
-li {
-    float: right;width: 80px;
-    text-align: center;
-}
+a { text-decoration: none; }
+a,a:visited { color: #0388ff}
+img { width: 100px;height: 100px; }
+ul { margin: 0;padding: 0; }
+li { float: right;width: 80px; text-align: center; }
+
 /*main*/
 #header {
     position:absolute;top: 0;
         text-align: center;
     }
     #status { position: relative;top: 8px;font-size: 17px;color: #ff3900; }
+    .jclock {
+        position: absolute;left: 270px;top: 8px;
+        width: 70px;height: 20px;
+        z-index: 1;
+        background: white;
+        font-size: 17px;color: #ff3900;
+    }
     #operate_manager {
-        position: absolute;top: 100px;
+        position: absolute;top: 5px;
         margin-left: 480px;
     }
 
 }
 
 
-/**/
+/*button in Header and Footer*/
 .indexButton, .indexButton:visited {
     display: block; padding: 4 8 3 10;
-    font-size: 17px;
     height: 20px;
-    color: #0388ff;
-    opacity: 0.4;
+    font-size: 17px; color: #0388ff; opacity: 0.4;
 }
-#indexButton1 {
-    float: left;
-    background: white; border-radius: 0 0 10 0;
-}
-#indexButton2 {
-}
+#indexButton1 { float: left; background: white; border-radius: 0 0 10 0; }
+#indexButton2 { }
+#indexButton3,#indexButton4 { background: white; }
 #indexButton3 {
     float: left;
-    background: white;
-    border-top: 1px solid #51c8df;border-right: 1px solid #51c8df;
-    border-radius: 0 10 0 0;
+    border-top: 1px solid #51c8df;border-right: 1px solid #51c8df; border-radius: 0 10 0 0;
 }
 #indexButton4 {
     float: right;
-    background: white;
-    border-top: 1px solid #51c8df;border-left: 1px solid #51c8df;
-    border-radius: 10 0 0 0;
+    border-top: 1px solid #51c8df;border-left: 1px solid #51c8df; border-radius: 10 0 0 0;
 }
-/*fancybox*/
+
+/*other button*/
+.bigButton {
+    display: block;
+    width: 80px;
+    margin: 0 auto;padding: 4 0 4 0;
+    border: 1px solid #7bc30a; border-radius: 8;
+    background: white;color: #7bc30a; font-size: 22px; text-align: center;
+}
+.bigButton:hover { background: #7bc30a;color: white; cursor: hand; }
+
+/*JS-plugin: fancybox*/
 .fancyboxContainer {
     width: 400px;height: 300px;
 }
+

static/css/department.css

+/*special*/
+input { width: 100px; }
+.unable,.unable:visited {
+    font-size: 12px;color: #999;
+    text-decoration: line-through;
+}
+a { cursor: pointer; }
+
+/*main*/
+.member_wrap {
+    border-left: 4px solid #7bc30a;
+    margin: 15 0 0 15;
+    padding: 5 0 5 4;
+}
+    /*dpmt*/
+.dpmt { height: 30px; overflow: hidden; }
+        #dpmt_input { float:left }
+        #dpmt_confirm { float:left }
+
+div.dpmt_operate {
+    float: left;height: 25px;
+    margin: 0 0 0 15px;
+}
+    a.dpmt_operate {
+        font-size: 12px;height: 20px;
+        color: #48c6de;
+    }
+    a.dpmt_operate:hover {
+        text-decoration: underline;
+    }
+
+#dpmt_name {
+    display: block;float: left;
+    color: #777;font-size: 16px;font-weight: bold;
+}
+
+    /*member*/
+.mems { width: 550px;overflow:hidden; }
+    .mem {
+        width: 60px;height: 75px;float: left;
+        margin: 0 8 0 0;padding: 5px;
+        background: #a4e2ee;
+        border-radius: 5;
+    }
+    .mem img {
+        width: 60px;height: 60px;
+    }
+    .mem_name {
+        width: 60px;height: 15px;
+        text-align: center;
+        color: #555;
+    }
+
+    /*add*/
+.add_operate {
+    overflow: hidden;width: 80px;height: 30px;
+    float: right;
+}
+
+#add { overflow: hidden; }
+    #add_main {
+        float:right;
+        width: 200px;height: 25px;
+        margin: 35 20 0 0;padding: 10px;
+        border: 1px solid #48c6de;
+    }
+        #add_elmt_plus {
+            float: left;
+            font-size: 35px;font-weight: bolder; color: #7bc30a;
+            position: relative;top: -10px;
+        }   
+        #add_click {
+            float: left; height: 30px;
+            margin: 2 0 0 5; color: #7bc30a;cursor: pointer;
+        }

static/css/home.css

 #operate_member {
     width: 80px;height:20px;
-    position: absolute;top: 100px;
+    position: absolute;top: 5px;
     margin: 0 0 0 15;
     overflow: hidden;
     font-size: 16px;

static/js/base.js

+//function used
+function chgStatus(s) {
+    $('.jclock').hide();
+    $('#status').html(s).show().fadeOut(1500,function(){ $('.jclock').show(500); });
+}
 $(document).ready(function() {
     //spring Help
     $('#indexButton3').fancybox({

static/js/dpmt.js

+/*page layout function*/
 function recomDelete() {
     len = $('.mem').length;
     for (var i=0;i<len;i++){
         type: 'GET',
         url: '/department/block/',
         success: function(block){
-            $('#main_container').html(block);
+            $('#member').html(block);
             recomDelete();
         }
     })
 }
-function Cancel() {
-    //lazy to write............
-    document.location.reload();
+/*function: member*/
+function Delete(id) {
+    $.ajax({
+        type: 'GET',
+        url: '/department/delete/',
+        data: 'id='+id,
+        success: function(status){
+            refresh();
+            chgStatus(status);
+        }
+    });
 }
-function hideInput() {
-    $('#add_input').hide();
+function Cancel_member(id) {
+    var DOMID = '#dpmt_' + id;
+    var _DOMID = '#_dpmt_' + id;
+    $(_DOMID).hide();
+    $(DOMID).show();
 }
-function showInputAdd() {
+function showChangeConfirm(id,name) {
+    var DOMID = '#dpmt_' + id;
+    var _DOMID = '#_dpmt_' + id;
+    $(DOMID).hide();
+    $(_DOMID).children().eq(0).children(":input").val(name);
+    $(_DOMID).show();
+}
+function Change(id) {
+    var DOMID = '#dpmt_input_' + id;
+    var to = $(DOMID).val();
+    $.ajax({
+        type: 'GET',
+        url: '/department/change/',
+        data: 'id='+id+'&to='+to,
+        success: function(status){
+            refresh();
+            chgStatus(status);
+        }
+    });
+    Cancel_member(id);
+}
+/*function: department*/
+function showAddConfirm() {
     $('#add_input').show().focus();
-    $('#addOperate').html('<a class="dpmt_operate" onClick="Add();">确认</a><a class="dpmt_operate" onClick="Cancel()">取消</a> ');
+    $('#add_operate').hide();
+    $('#add_confirm').show();
 }
 function Add() {
     var name = $('#add_input').val();
     hideInput();
     $('#addOperate').html('<a onClick="showInputAdd();">Add</a>');
 }
-function Delete(name) {
-    var name = name.getAttribute('name');
-    $.ajax({
-        type: 'GET',
-        url: '/department/delete/',
-        data: 'name='+name,
-        success: function(status){
-            refresh();
-            $('#status').html(status);
-            recomDelete();
-        }
-    });
+function Cancel_dpmt() {
+    $('#add_confirm').hide();
+    $('#add_input').hide();
+    $('#add_operate').show();
 }
-function showInputChange(name) {
-    var name = name.getAttribute('name');
-    var arg = "#dpmt_name[name='" + name +"']";
-    $(arg).html('<input class=change_input name='+name+' value='+name+' />');
-    var arg1 = '#cdOperate_' + name;
-    $(arg1).html('<a class="dpmt_operate" onClick=Change("'+name+'");>确认</a><a class="dpmt_operate" onClick="Cancel()">取消</a>');
-}
-function Change(name) {
-    var name = name;
-    var arg = ".change_input[name='" + name +"']";
-    var to = $(arg).val();
-    $.ajax({
-        type: 'GET',
-        url: '/department/change/',
-        data: 'name='+name+'&to='+to,
-        success: function(status){
-            refresh();
-            $('#status').html(status);
-            recomDelete();
-        }
-    });
-}
+/*on ready*/
+$(function(){
+    recomDelete();
+});

static/js/home.js

         a.append(div);
     }
     //start clock
-    $('#status').jclock();
+    $('.jclock').jclock();
 });

static/js/login-and-logout.js

 $(document).ready(function() {
     //function used
     function chgStatus(s) {
-        $('#status').html(s).fadeOut('slow').fadeIn(1000);
+        $('.jclock').hide();
+        $('#status').html(s).fadeOut(1500,function(){ $('.jclock').show(500); });
     }
     $('#loginButton').fancybox({
         'titlePosition': 'inside',

templates/base.html

                 </ul>
             </div>
         </div>
-        <div id=container>
+        <div id=container style="position: relative;">
             <!--relative: absolute定位问题-->
             <div class=status>
-                <div id="status">{{ condition }}</div>
+                <div id="status"></div>
             </div>
+            <div class="jclock"></div>
             <div id="operate_manager">
             {% if user.is_authenticated %}
                 <a href="/department/">成员</a>

templates/dpmt/dpmt.html

 {% endblock %}
 
 {% block head_extra %}
-<style>
-    input {
-        width: 100px;
-    }
-    .unable,.unable:visited {
-        font-size: 12px;color: #999;
-        text-decoration: line-through;
-    }
-    #wrapper { overflow: hidden; }
-    #main_container { float: left; }
-    /**/
-    .dpmt_mem {
-        border-left: 4px solid #7bc30a;
-        margin: 15 0 0 15;
-        padding: 5 0 5 4;
-    }
-        .dpmt {
-            height: 30px; overflow: hidden;
-        }
-            #dpmt_name {
-                display: block;float: left;
-                color: #777;font-size: 16px;font-weight: bold;
-            }
-            div.dpmt_operate {
-                float: left;height: 25px;
-                margin: 0 0 0 15px;
-            }
-                a.dpmt_operate {
-                    font-size: 12px;height: 20px;
-                    color: #48c6de;
-                }
-                a.dpmt_operate:hover {
-                    text-decoration: underline;
-                }
-        .mem {
-            width: 550px;overflow:hidden;
-        }
-            #mem {
-                width: 60px;height: 75px;float: left;
-                margin: 0 8 0 0;padding: 5px;
-                background: #a4e2ee;
-                border-radius: 5;
-            }
-                #mem img {
-                    width: 60px;height: 60px;
-                }
-                #mem_name {
-                    width: 60px;height: 15px;
-                    text-align: center;
-                    color: #555;
-                }
-    #addArea {
-        border: 1px solid #48c6de;width: 200px;height: 30px;
-        margin: 35 20 0 0;padding: 10px;
-        float: right;
-    }
-        #addOperate {
-            overflow: hidden;width: 80px;height: 30px;
-            float: right;
-        }
-            #_add {
-                float: left;
-                font-size: 35px;font-weight: bolder;
-                color: #7bc30a;
-                position: relative;top: -10px;
-            }   
-            #addClick {
-                float: left; height: 30px;
-                margin: 2 0 0 5; color: #7bc30a;
-            }
-</style>
-<script type="text/javascript" src="/static/js/dpmt.js"></script>
-<script>
-    $(function(){
-        hideInput();
-        recomDelete();
-    });
-</script>
+    <link rel="stylesheet" type="text/css" href="/static/css/department.css" />
+    <script type="text/javascript" src="/static/js/dpmt.js"></script>
 {% endblock %}
 
 {% block container %}
-<div id="wrapper">
-    <div id=main_container>
-    {% for dpmt,mem_list in dpmt_mem_list %}
-    <div class="dpmt_mem">
-        <div class="dpmt" id="dpmt_{{ dpmt.name }}">
-            <div id="dpmt_name" name="{{ dpmt.name }}">{{ dpmt.name }}</div>
-            <div class="dpmt_operate" id=cdOperate_{{ dpmt.name }}>
-                <a class="dpmt_operate" href="#" onClick="showInputChange(this);" name="{{ dpmt.name }}">修改</a>
-                <a class="dpmt_operate" href="#" onClick="Delete(this);" id="dpmt_delete_{{ forloop.counter }}"
-                    name="{{ dpmt.name }}"
-                >删除</a>
+    <div id="member">
+        {% for dpmt,mem_list in dpmt_mem_list %}
+        <div class="member_wrap">
+
+            <div class="dpmt" id="dpmt_{{ dpmt.id }}">
+                <div id="dpmt_name">{{ dpmt.name }}</div>
+                <div class="dpmt_operate">
+                    <a class="dpmt_operate" href="#"
+                        onClick="showChangeConfirm({{ dpmt.id }},'{{ dpmt.name }}');"
+                    >修改</a>
+                    <a class="dpmt_operate" href="#"
+                        onClick="Delete({{ dpmt.id }});" id="dpmt_delete_{{ forloop.counter }}"
+                    >删除</a>
+                </div>
+            </div>
+            <!--below is hidden by default-->
+            <div class="dpmt" id="_dpmt_{{ dpmt.id }}" style="display:none">
+                <div id="dpmt_input"><input id="dpmt_input_{{ dpmt.id }}" class="dpmt_input" /></div>
+                <div id="dpmt_confirm">
+                    <a class="dpmt_operate" onClick="Change({{ dpmt.id }})">确认</a>
+                    <a class="dpmt_operate" onClick="Cancel_member({{ dpmt.id }})">取消</a>
+                </div>
+            </div>
+
+            <div id="mem_list_{{ forloop.counter }}" class="mems">
+                {% for mem in mem_list %}
+                <div class=mem>
+                    <img src="{{ mem.img_head.url }}">
+                    <div class=mem_name>{{ mem.name }}</div>
+                </div>
+                {% endfor %}
             </div>
         </div>
-        <div id=mem_list_{{ forloop.counter }} class="mem">
-            {% for mem in mem_list %}
-            <div id=mem>
-                <img src="{{ mem.img_head.url }}">
-                <div id=mem_name>{{ mem.name }}</div>
+        {% endfor %}
+    </div>
+
+    <div id=add>
+        <div id=add_main>
+            <input name="dpmt_name" id="add_input" style="display:none"/>
+            <div id=add_operate class=add_operate>
+                <div id=add_elmt_plus>+</div><div id="add_click" onClick="showAddConfirm();">添加</div>
             </div>
-            {% endfor %}
+            <!--below is hidden by default-->
+            <div id="add_confirm" class="add_operate" style="display:none">
+                <a class="dpmt_operate" onClick="Add();">确认</a>
+                <a class="dpmt_operate" onClick="Cancel_dpmt()">取消</a> 
+            </div>
         </div>
     </div>
-    {% endfor %}
-    </div>
-    <div id=addArea>
-        <input name="dpmt_name" id="add_input"/>
-        <div id=addOperate>
-            <div id=_add>+</div><div id="addClick" onClick="showInputAdd();">添加</div>
-        </div>
-    </div>
-</div>
 {% endblock %}

templates/dpmt/dpmt_block.html

-    {% for dpmt,mem_list in dpmt_mem_list %}
-    <div class="dpmt_mem">
-        <div class="dpmt" id="dpmt_{{ dpmt.name }}">
-            <div id="dpmt_name" name="{{ dpmt.name }}">{{ dpmt.name }}</div>
-            <div class="dpmt_operate" id=cdOperate_{{ dpmt.name }}>
-                <a class="dpmt_operate" href="#" onClick="showInputChange(this);" name="{{ dpmt.name }}">修改</a>
-                <a class="dpmt_operate" href="#" onClick="Delete(this);" id="dpmt_delete_{{ forloop.counter }}"
-                    name="{{ dpmt.name }}"
-                >删除</a>
+        {% for dpmt,mem_list in dpmt_mem_list %}
+        <div class="member_wrap">
+
+            <div class="dpmt" id="dpmt_{{ dpmt.id }}">
+                <div id="dpmt_name">{{ dpmt.name }}</div>
+                <div class="dpmt_operate">
+                    <a class="dpmt_operate" href="#"
+                        onClick="showChangeConfirm({{ dpmt.id }},'{{ dpmt.name }}');"
+                    >修改</a>
+                    <a class="dpmt_operate" href="#"
+                        onClick="Delete({{ dpmt.id }});" id="dpmt_delete_{{ forloop.counter }}"
+                    >删除</a>
+                </div>
+            </div>
+            <!--below is hidden by default-->
+            <div class="dpmt" id="_dpmt_{{ dpmt.id }}" style="display:none">
+                <div id="dpmt_input"><input id="dpmt_input_{{ dpmt.id }}" class="dpmt_input" /></div>
+                <div id="dpmt_confirm">
+                    <a class="dpmt_operate" onClick="Change({{ dpmt.id }})">确认</a>
+                    <a class="dpmt_operate" onClick="Cancel_member({{ dpmt.id }})">取消</a>
+                </div>
+            </div>
+
+            <div id="mem_list_{{ forloop.counter }}" class="mems">
+                {% for mem in mem_list %}
+                <div class=mem>
+                    <img src="{{ mem.img_head.url }}">
+                    <div class=mem_name>{{ mem.name }}</div>
+                </div>
+                {% endfor %}
             </div>
         </div>
-        <div id=mem_list_{{ forloop.counter }} class="mem">
-            {% for mem in mem_list %}
-            <div id=mem>
-                <img src="{{ mem.img_head.url }}">
-                <div id=mem_name>{{ mem.name }}</div>
-            </div>
-            {% endfor %}
-        </div>
-    </div>
-    {% endfor %}
+        {% endfor %}

templates/home/home.html

     <!--JS-plugin: jclock--> <script type="text/javascript" src="/static/js/jclock.js"></script>
     <!--JS: fancybox. login and logout--> <script type="text/javascript" src="/static/js/login-and-logout.js"></script>
     <!--JS: home.ready--> <script type="text/javascript" src="/static/js/home.js"></script>
+    <script>
+        function chgStatus(s) {
+            $('.jclock').hide();
+            $('#status').html(s).fadeOut(1500,function(){ $('.jclock').show(500); });
+        }
+        //为何函数在文件中时页面不能调用(其他情况不知,仅这个而言)
+        $(document).ready(function () {
+            chgStatus('{{ status }}');
+        });
+    </script>
 {% endblock %}
 
 {% block container %}