Exemple #1
0
def wiki_content(request, name, path):
    project = q_get(Project, name=name)
    resp = can_access(project, request.user)
    if resp != None:
        return resp

    rc = request.rc
    rc.project = project
    rc.navmenus = build_prj_nav_menu(request, project, 'wiki')

    rc.pagename = path

    rc.can_op = can_write(project, request.user)
    rc.wiki = q_get(WikiContent, project=project, path=path)

    if request.method == 'POST' and rc.can_op:
        atts = request.FILES.getlist('attachment')
        fc = 0

        for f in atts:
            if fc <= prj_key.get(project, prj_key.UPLOAD_LIMIT_COUNT, 5):
                add_file(request, project, 'wiki', rc.wiki.id, f)
                fc += 1

    if rc.wiki is not None:
        rc.wiki.content = safe_esc(rc.wiki.content)

        rc.files = q_gets(ProjectAttachment,
                          project=project,
                          ftype='wiki',
                          ftid=int(rc.wiki.id),
                          status=consts.FILE_ENABLE).order_by('-ctime')

    return send_response(request, 'wiki/view.html')
Exemple #2
0
def wiki_index(request, name):
    #list all page
    project = q_get(Project, name=name)
    resp = can_access(project, request.user)
    if resp != None:
        return resp

    path = prj_key.get(project, prj_key.WIKI_INDEX, 'index')
   
    return redirect(reverse('apps.wiki.views.wiki_content', args=[name, path]))
Exemple #3
0
def wiki_index(request, name):
    #list all page
    project = q_get(Project, name=name)
    resp = can_access(project, request.user)
    if resp != None:
        return resp

    path = prj_key.get(project, prj_key.WIKI_INDEX, 'index')

    return redirect(reverse('apps.wiki.views.wiki_content', args=[name, path]))
Exemple #4
0
def new_issue(request, name):
    rc = request.rc
    project = q_get(Project, name = name)
    
    resp = can_access(project, request.user)
    if resp != None:
        return resp

    rc.project = project
    rc.pagename = 'create issue'
    rc.navmenus = build_prj_nav_menu(request, rc.project, 'issues')

    if request.method != 'POST':
        return send_response(request, 
                         'issue/new.html')
    
    title = request.POST.get('title', '')
    content = request.POST.get('content', '')
    
    if len(title) <= 0:
        return send_response(request, 
                             'issue/new.html')
    
    if len(content) <= 0:
        return send_response(request, 
                             'issue/new.html')
    
    issue = Issue()
    issue.project = rc.project
    
    issue.creator = request.user

    issue.title = title
    issue.content = content
    issue.status = consts.ISSUE_OPEN
    issue.vote_count = 0
    
    issue.save()

    # add file
    atts = request.FILES.getlist('attachment')
    fc = 0
    for f in atts:
        if fc <= prj_key.get(project, prj_key.UPLOAD_LIMIT_COUNT, 5):
            add_file(request, project, 'issue', issue.id, f)
            fc += 1

    activity.new_issue(rc.project, request.user, issue)

    return redirect(reverse('apps.issue.views.view_issue', 
                            args=[name, issue.id]))
Exemple #5
0
def new_issue(request, name):
    rc = request.rc
    project = q_get(Project, name=name)

    resp = can_access(project, request.user)
    if resp != None:
        return resp

    rc.project = project
    rc.pagename = 'create issue'
    rc.navmenus = build_prj_nav_menu(request, rc.project, 'issues')

    if request.method != 'POST':
        return send_response(request, 'issue/new.html')

    title = request.POST.get('title', '')
    content = request.POST.get('content', '')

    if len(title) <= 0:
        return send_response(request, 'issue/new.html')

    if len(content) <= 0:
        return send_response(request, 'issue/new.html')

    issue = Issue()
    issue.project = rc.project

    issue.creator = request.user

    issue.title = title
    issue.content = content
    issue.status = consts.ISSUE_OPEN
    issue.vote_count = 0

    issue.save()

    # add file
    atts = request.FILES.getlist('attachment')
    fc = 0
    for f in atts:
        if fc <= prj_key.get(project, prj_key.UPLOAD_LIMIT_COUNT, 5):
            add_file(request, project, 'issue', issue.id, f)
            fc += 1

    activity.new_issue(rc.project, request.user, issue)

    return redirect(
        reverse('apps.issue.views.view_issue', args=[name, issue.id]))
Exemple #6
0
def wiki_content(request, name, path):
    project = q_get(Project, name=name)
    resp = can_access(project, request.user)
    if resp != None:
        return resp


    rc = request.rc
    rc.project = project
    rc.navmenus = build_prj_nav_menu(request, project, 'wiki')

    rc.pagename = path
                            
    rc.can_op = can_write(project, request.user)
    rc.wiki = q_get(WikiContent, project = project, path=path)

    if request.method == 'POST' and rc.can_op:
        atts = request.FILES.getlist('attachment')
        fc = 0

        for f in atts:
            if fc <= prj_key.get(project, prj_key.UPLOAD_LIMIT_COUNT, 5):
                add_file(request, project, 'wiki', rc.wiki.id, f)
                fc += 1

    if rc.wiki is not None:
        rc.wiki.content = safe_esc(rc.wiki.content)

        rc.files = q_gets(ProjectAttachment, project = project, 
                          ftype = 'wiki',
                          ftid = int(rc.wiki.id),
                          status = consts.FILE_ENABLE).order_by('-ctime')
        
    
    return send_response(request, 
                         'wiki/view.html')
Exemple #7
0
def new_issue(request, name):
    rc = request.rc
    project = q_get(Project, name=name)

    resp = can_access(project, request.user)
    if resp != None:
        return resp

    rc.project = project
    rc.pagename = 'create issue'
    rc.navmenusSource = build_prj_nav_menu(request, rc.project, 'issues')

    if request.method != 'POST':
        return send_response(request, 'issue/new.html')

    title = request.POST.get('title', '')
    content = request.POST.get('content', '')

    if len(title) <= 0:
        return send_response(request, 'issue/new.html')

    if len(content) <= 0:
        return send_response(request, 'issue/new.html')

    issue = Issue()
    issue.project = rc.project

    issue.creator = request.user

    issue.title = title
    issue.content = content
    issue.status = consts.ISSUE_OPEN
    issue.vote_count = 0

    issue.save()

    #admin = q_get(User, name='taocodeadmin')

    admin = q_get(User, name=request.user)

    project = q_get(Project, name=rc.project)

    owner = q_get(User, name=project.owner)

    content = "System message: The project " + rc.project.name + " have an issue . http://code.taobao.org/p/" + project.name + "/issues/ . Please check it."
    send_newissuemsg(request, owner, admin, content)

    members = q_gets(ProjectMember,
                     project=project,
                     member_type=consts.PM_ACCEPT_INV)

    for m in members:
        send_newissuemsg(request, m.user, admin, content)

    # add file
    atts = request.FILES.getlist('attachment')
    fc = 0
    for f in atts:
        if fc <= prj_key.get(project, prj_key.UPLOAD_LIMIT_COUNT, 5):
            add_file(request, project, 'issue', issue.id, f)
            fc += 1

    activity.new_issue(rc.project, request.user, issue)

    return redirect(
        reverse('apps.issue.views.view_issue', args=[name, issue.id]))