Beispiel #1
0
def index(request):
    '''index view'''

    pfix = "index"

    WEIGHT_KEYS = WEIGHT.keys()
    WEIGHT_KEYS.sort()
    icon_guide_html = ""
    for key in WEIGHT_KEYS:
        icon_guide_html += '''<i class="item ''' + key + '''">&nbsp;</i>''' + WEIGHT[key]

    allProjects = sm.Project.objects.all().order_by("-id")
    allTasks = sm.Task.objects.all().order_by("-id")
    allUsers = sm.User.objects.all().order_by("department")

    session = request.session

    uid = request.session.get("uid",None)
    try:
        cuser = sm.User.objects.get(id = uid)		
    except sm.User.DoesNotExist:
        cuser = None

    return render_to_response("system/index.html",locals())
Beispiel #2
0
def v(request,t = "", tid = ""):
    '''user view'''

    uid = request.session.get("uid",0)

    if uid:
        cuser = sm.User.objects.get(id = uid)
    else:
        cuser = None


    WEIGHT_KEYS = WEIGHT.keys()
    WEIGHT_KEYS.sort()
    icon_guide_html = ""
    for key in WEIGHT_KEYS:
        icon_guide_html += '''<i class="item ''' + key + '''">&nbsp;</i>''' + WEIGHT[key]

    if t == "user" and tid == str(uid):
        pfix = "gallery"
        uname = u"我"
    else:
        pfix = t
        try:
            uname = sm.User.objects.get(id = tid).name_zh
        except sm.User.DoesNotExist:
            pass

    if t:
        try:
            model = sm.__dict__[t.capitalize()]
        except KeyError:
            return HttpResponse(u"404 page")
        allProjects = sm.Project.objects.all()
        allUsers    = sm.User.objects.all()
        allTasks    = sm.Task.objects.all()
        allGroups   = sm.Group.objects.all()
        allRights   = sm.Rights.objects.all()
    if not t and not tid:
        return HttpResponseRedirect("/")
    elif t and not tid:
        templates = "system/list_" + t + ".html"
        return render_to_response(templates,locals())
    else:
        templates = "system/details_" + t + ".html"
        obj = model.objects.get(id = tid)
        if t == "project":
            related_tasks = sm.Task.objects.filter(pid = tid).order_by("-id")
            related_users = sm.User_Project.objects.filter(pid = tid).order_by("-id")
            pattern = "\.pyc$|^\.|\.py$|_import.html|.*footer.*"
            path = sc.P_PROJECT_PATH + "/" + obj.name_en
            dirHtml = dirTree(path, "/p/", pattern)
            static_dir = sc.P_STATIC_PATH + "/" + obj.name_en

            psd_dir = sc.P_STATIC_PATH + "/" + obj.name_en + "/_psd"

            try:
                psd_prefix_file = open(psd_dir + "/.filelist")
                psd_prefix = cp.load(psd_prefix_file).get("prefix","")
                psd_prefix_file.close()
            except:
                psd_prefix = ""


            staticHtml = dirTree(sc.P_STATIC_PATH + "/" + obj.name_en,'/s/static/',"\.pyc$|^\.|\.py$|^font$|^_psd$",tid = "J_static_dir")
            #----ry code
            dirHtml = dirHtml
            #----ry code
        elif t == "task":
            related_users = sm.User_Task.objects.filter(tid = tid).order_by("-id")
        elif t == "user":
            related_tasks = sm.User_Task.objects.filter(uid = tid).order_by("-id")
            related_projects = sm.User_Project.objects.filter(uid = tid).order_by("-id")
        return render_to_response(templates,locals())