Design and implementation of asset management system based on Python+Web+Django+sqlite

Contents
Chapter 1 Introduction 2
1.1 Background and significance of the research work 2
1.2 Main contribution and innovation of this paper 2 1.3
Structural arrangement of this paper 2
2.1 Requirements analysis 3
2.2 ER diagram 3
2.2.1 Design of local ER model 3
2.2.2 Design of global ER diagram 9
2.4 Conversion of ER model to data model 9
2.5 Data dictionary 10
2.6 Logical design of database 14
Chapter 3 Backend design of website 17
3.1 Selection of backend framework 17
3.2 Framework overview 17
3.3 Request response 17
3.3.1 Domain name Analysis 17
3.3.2 View return 18
3.3 Connection with database 18
Chapter 4 Overall design of the website 20
4.1 Website homepage 20
4.2 Login and registration 25
4.2.1 Registration system 25
4.2.2 Login interface 31
4.2.3 Password in the database Storage in 33
4.3 Department and authority management 35
4.3.1 Department and authority management interface 35
4.3.2 Implementation of authority management 37
4.4 Invitation code mechanism 38
4.4.1 Interface and function of invitation code system 38
4.4.2 Implementation of invitation code 41
4.5 Employee management system 41
4.6 Asset management part 43
4.6.1 Asset list 43
4.6.2 Asset registration management system 45
4.6.3 Asset claim management system 48
4.6.4 Asset maintenance management system 50
4.6.5 Depreciation management system 51
4.6. 6 Depreciation record rollback and recovery mechanism 54
4.7 Overall frame of system functions 56
Chapter 4 Full text summary and outlook 57
4.1 Full text summary 57
4.2 Follow-up work outlook 57
Acknowledgments 57
References 57
Chapter 2 Design of database model
2.1 Requirements analysis
of this system The basic requirement is to implement the following functions or modules:
(1) Asset registration management module: add, delete, modify and check asset information;
(2) Asset requisition management module: add, delete, modify and check asset requisition records;
(3) Asset depreciation management module: according to different Calculate the depreciation amount and residual value of assets using the depreciation method;
(4) Maintenance management module: Add, delete, modify and check maintenance record information
(5) Employee and department management module: You can add and delete employees and departments
(6) Permission management module: Record employees and Department permission information
(7) Login registration module: realize user login and registration
(8) Invitation code module: invitation code contains permission information, users can automatically obtain the permission information of the corresponding module after using the invitation code to register
(9) Use GUI Or website design to realize human-computer friendly interactive interface
Therefore, the important information managed in this system mainly includes: asset information, asset utilization information, asset depreciation information, maintenance record information, etc. Therefore, the following four tables are needed to store this part of information: asset information table, asset acquisition record table, asset depreciation record table and maintenance record table. In order to reach the third normal form, we need to eliminate dependencies, so we add an additional asset class table.
In order to realize multi-user login and management, it is also necessary to manage user accounts, permissions, departments and other information. Therefore, the database also includes employee information tables, department information tables, user information tables, and permission information tables.
In order to implement the invitation code function, a table is added to store the invitation code information.

# coding=utf-8
from django.shortcuts import render, render_to_response
from django.http import HttpResponse
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from django.views.decorators.csrf import csrf_protect
from django.contrib.auth.hashers import make_password
from django.contrib import messages
from django.template import loader
import urllib.request
import sys

sys.path.append('G:\Database-APP\DatabaseAPP')
from assets.models import Staff, InviteCode


# Create your views here.

class UserForm(forms.Form):
    username = forms.CharField(label='用户名', max_length=50)
    password = forms.CharField(label='密码', widget=forms.PasswordInput())
    password_repeat = forms.CharField(label='重复密码', widget=forms.PasswordInput())
    last_name = forms.CharField(label='姓')
    first_name = forms.CharField(label='名')
    email = forms.EmailField(label='邮箱')
    invite_code = forms.CharField(label='邀请码(选填)', max_length=100, required=False)
    # first_name = forms.CharField(label='名')
    # last_name = forms.CharField(label='姓')


@csrf_protect
def regist(request):
    ticket = request.GET.get('ticket')
    randstr = request.GET.get('randstr')
    ip = request.GET.get('ip')
    if randstr:
        textmod = {
    
    'aid': '2036447301', 'AppSecretKey': '0CQuV8SIDluGCVpMcfAPwgA**', 'Ticket': ticket, 'UserIP': ip,
                   'Randstr': randstr}
        textmod = urllib.parse.urlencode(textmod)
        req = urllib.request.Request(url='%s%s%s' % ("https://ssl.captcha.qq.com/ticket/verify", '?', textmod))
        res = urllib.request.urlopen(req)
        print(res.read())
        res.close()

    if request.method == 'POST':
        userform = UserForm(request.POST)
        print(userform)
        if userform.is_valid():
            username = userform.cleaned_data['username']
            if User.objects.filter(username=username):
                messages.error(request, '用户已存在!')
                return render(request, "regist.html", {
    
    'userform': userform})

            password = userform.cleaned_data['password']
            password_repeat = userform.cleaned_data['password_repeat']
            if password != password_repeat:
                messages.error(request, '两次输入的密码不同!')
                return render(request, "regist.html", {
    
    'userform': userform})
            email = userform.cleaned_data['email']
            password = make_password(password, None, 'pbkdf2_sha256')

            invite_code = userform.cleaned_data['invite_code']
            first_name = userform.cleaned_data['first_name']
            last_name = userform.cleaned_data['last_name']

            user = User.objects.create(username=username, password=password, email=email, is_staff=True,
                                       first_name=first_name,
                                       last_name=last_name)
            # User.save()
            if invite_code:
                import base64
                invite_code=str.encode(invite_code)
                try:
                    invite_code_id = int(base64.b64decode(invite_code).decode().split()[0])
                except:
                    messages.error(request, '邀请码错误!')
                    return render(request, "regist.html", {
    
    'userform': userform})
                code_obj=InviteCode.objects.get(id=invite_code_id)
                if code_obj.key == invite_code.decode():
                    if code_obj.times:
                        Staff.objects.create(staff_name=last_name + first_name, staff_user=user, staff_dep= code_obj.dept)
                        user.groups.add(code_obj.dept.dep_permmison)
                        code_obj.times -= 1
                        code_obj.save()
                else:
                    messages.error(request, '邀请码错误或失效!')
                    return render(request, "regist.html", {
    
    'userform': userform})

            else:
                Staff.objects.create(staff_name=last_name + first_name, staff_user=user)
            messages.success(request, "注册成功")
    else:
        userform = UserForm()

    # return render_to_response('regist.html', {'userform': userform})
    return render(request, "regist.html", {
    
    'userform': userform})


def index(request):
    # template = loader.get_template('register/index.html')
    # return HttpResponse(template.render(request))
    return render(request, "index_home.html", {
    
    })

Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/newlw/article/details/132893926