Ejemplo n.º 1
0
def add_project(request, redirect, kw):
    form_content = parse_user_sessions(request)

    if ("project_name" not in form_content
            or "project_description" not in form_content
            or "project_date" not in form_content):
        raise Missing_Data()

    projects = get_json(PROJECTS)

    new_project = {}

    id_new_project = os.urandom(16).hex()

    new_project[id_new_project] = {
        "project_name": "",
        "project_description": "",
        "project_date": "",
    }

    for item in form_content:
        if item in new_project[id_new_project]:
            new_project[id_new_project][item] = form_content[item]

    projects.update(new_project)

    save_data(PROJECTS, projects)

    return HttpResponseRedirect(redirect)
Ejemplo n.º 2
0
def save_user_session(request, session, file_name):
    session_id = os.urandom(16).hex()
    sessions = get_json(file_name)
    sessions[session_id] = session
    save_data(file_name, sessions)

    return session_id
Ejemplo n.º 3
0
def get_editing_page(request, **kw):
    project_id = kw["project_id"]
    projects = get_json(PROJECTS)
    certain_project = projects[project_id]
    editing_page = get_content(
        PORTFOLIO / "test_projects" /
        "edit_projects.html").format(**certain_project, project_id=project_id)
    return HttpResponse(editing_page)
Ejemplo n.º 4
0
def edit_project(request, redirect, kw):
    form = parse_user_sessions(request)
    projects = get_json(PROJECTS)

    # if "project_id" not in form:
    #     raise Missing_Data()

    project_id = kw["project_id"]
    for item in form:
        projects[project_id][item] = form[item]

    save_data(PROJECTS, projects)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 5
0
def projects_GETresponse(request, redirect, kw):
    visits_counter(request.path)
    projects_content = get_json(PROJECTS)
    template = get_content(PROJECTS_TEMPLATE)
    projects = ""

    for project in projects_content:
        projects += template.format(
            project_name=projects_content[project]["project_name"],
            project_id=project,
            project_date=projects_content[project]["project_date"],
            project_description=projects_content[project]
            ["project_description"],
        )

    page_content = get_content(PROJECTS_INDEX).format(projects=projects)
    return HttpResponse(page_content, "text/html")
Ejemplo n.º 6
0
def delete_project(request, redirect, kw):
    project_id = kw["project_id"]
    projects = get_json(PROJECTS)
    projects.pop(project_id)
    save_data(PROJECTS, projects)
    return HttpResponseRedirect(redirect)
from testcase.base_setup import BaseSetup
from interfaces.warehousing import *
import ddt
from utils.json_utils import get_json
from utils.decorator import desc
import unittest
'''
desc装饰起仅调用runner可用
如果想通过unittest运行,不能使用desc
解释:
    1. unittest默认会把__doc__赋值_testMethodDoc
    2. 通过unittest会比装饰器更早初始化
    3. _testMethodDoc的值不能在初始化前修改
    4. 在初始化后修改_testMethodDoc会导致崩毁(unitetest有验证)
'''
create_orde_data = get_json("ware_housing.json")["create_orde_data"]


@ddt.ddt
class warehousing_test(BaseSetup):
    @desc
    @ddt.data(*create_orde_data)
    def test_create_orde1(self, data):
        '''测试转运入库订单生成'''
        create_orde(json=data['data'])

    def test_chargeback1(self):
        '''取消转运订单:'''
        pass

    def test_update_logistics1(self):
Ejemplo n.º 8
0
    def get_context_data(self, **kwargs):
        ctx = super().get_context_data(**kwargs)
        edu_info = get_json(EDUCATION)
        ctx.update({"edu_info": edu_info})

        return ctx