Example #1
0
def project_issue_file(request, project_slug, file_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    file = get_object_or_404(models.FileUpload, id=file_id)
    can_view, can_edit, can_modify = utils.check_perms(request, project)

    if settings.WEB_SERVER == 'nginx':
        if can_view is False:
            return HttpResponseNotFound()
        else:
            response = HttpResponse()
            response['Content-Type'] = ""
            response['X-Accel-Redirect'] = file.get_absolute_url()
            return response

    elif settings.WEB_SERVER == 'apache':
        if can_view is False:
            return HttpResponseNotFound()
        else:
            response = HttpResponse()
            response['X-Sendfile'] = os.path.join(
                settings.MEDIA_ROOT, file.file.path)
            content_type, encoding = mimetypes.guess_type(
                file.file.read())
            if not content_type:
                content_type = 'application/octet-stream'
            response['Content-Type'] = content_type
            response['Content-Length'] = file.file.size
            response['Content-Disposition'] = 'attachment; filename="%s"' % \
                file.file.name
            return response
    else:
        return HttpResponseNotFound()
Example #2
0
def submit_issue(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    if request.user.id:
        try:
            profile = request.user.userprofile
            profile_id = profile.id
        except AttributeError:
            profile_id = None
    else:
        profile_id = None
    if can_comment is False:
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.IssueForm(project.id, can_edit, request.POST)
            if form.is_valid():
                issue = form.save()
                return HttpResponseRedirect(issue.get_absolute_url())
        else:
            if request.user:
                form = forms.IssueForm(project.id, can_edit, 
                    initial={ 'project': project.id, 'created_by': profile_id})
            else:
                form = forms.IssueForm(project.id, can_edit,
                    initial={ 'project': project.id })
        return render_to_response(
            "djtracker/submit_issue.html", locals(),
            context_instance=RequestContext(request))
Example #3
0
def project_issue_file(request, project_slug, file_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    file = get_object_or_404(models.FileUpload, id=file_id)
    can_view, can_edit, can_modify = utils.check_perms(request, project)

    if settings.WEB_SERVER == 'nginx':
        if can_view is False:
            return HttpResponseNotFound()
        else:
            response = HttpResponse()
            response['Content-Type'] = ""
            response['X-Accel-Redirect'] = file.get_absolute_url()
            return response

    elif settings.WEB_SERVER == 'apache':
        if can_view is False:
            return HttpResponseNotFound()
        else:
            response = HttpResponse()
            response['X-Sendfile'] = os.path.join(
                settings.MEDIA_ROOT, file.file.path)
            content_type, encoding = mimetypes.guess_type(
                file.file.read())
            if not content_type:
                content_type = 'application/octet-stream'
            response['Content-Type'] = content_type
            response['Content-Length'] = file.file.size
            response['Content-Disposition'] = 'attachment; filename="%s"' % \
                file.file.name
            return response
    else:
        return HttpResponseNotFound()
Example #4
0
def project_all_issues(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issues = project.issue_set.all()
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    status_choices = models.Status.objects.all()
    priority_choices = models.Priority.objects.all()
    type_choices = models.IssueType.objects.all()
    if 'component' in request.GET:
        if request.GET.get('component'):
            issues = issues.filter(component__slug=request.GET.get('component'))
    if 'version' in request.GET:
        if request.GET.get('version'):
            issues = issues.filter(version__slug=request.GET.get('version'))
    if 'milestone' in request.GET:
        if request.GET.get('milestone'):
            issues = issues.filter(milestone__slug=request.GET.get('milestone'))
    if 'status' in request.GET:
        if request.GET.get('status'):
            issues = issues.filter(status__slug=request.GET.get('status'))
    if 'type' in request.GET:
        if request.GET.get('type'):
            issues = issues.filter(issue_type__slug=request.GET.get('type'))
    if 'priority' in request.GET:
        if request.GET.get('priority'):
            issues = issues.filter(priority__slug=request.GET.get('priority'))

    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_view_all.html", locals(),
            context_instance=RequestContext(request))
Example #5
0
def view_issue(request, project_slug, issue_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, id=issue_id)
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    
    # get action log
    action_log = []
    issue_log = list(models.IssueLog.objects.filter(issue=issue).order_by('timestamp'))
    comments = list(CommentWithIssueStatus.objects.filter(object_pk=issue.pk).order_by('submit_date'))
    # mix comments and issue log
    while True:
        if len(issue_log)>0 and len(comments)>0:
            if issue_log[0].timestamp<=comments[0].submit_date:
                action_log.append(('issue_log', issue_log.pop(0)))
            else:
                action_log.append(('comment', comments.pop(0)))
        elif len(issue_log)>0:
            action_log.append(('issue_log', issue_log.pop(0)))
        elif len(comments)>0:
            action_log.append(('comment', comments.pop(0)))
        else:
            break                 
    ## Check if we're watching
    is_watching = False
    if request.user.is_authenticated():
        try:
            profile = models.UserProfile.objects.get(user=request.user)
        except ObjectDoesNotExist:
            is_watching = False
            profile = None
        if profile in issue.watched_by.all():
            is_watching = True

    ## Check for GET variables
    if "watch" in request.GET and can_view:
        if request.GET['watch'] == "yes":
            try:
                profile = models.UserProfile.objects.get(user=request.user)
            except ObjectDoesNotExist:
                profile = models.UserProfile.create(user=request.user)
                profile.save()
            issue.watched_by.add(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.id])
            )
        elif request.GET['watch'] == "no":
            profile = models.UserProfile.objects.get(user=request.user)
            issue.watched_by.remove(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.id])
            )
                
    ## Check if we can view
    if can_view is False: 
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_detail.html", locals(),
            context_instance=RequestContext(request))
Example #6
0
def project_version(request, project_slug, modi_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    modifier = get_object_or_404(models.Version, slug=modi_slug)
    modifier_type = "Version"
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/modifier_view.html", locals(),
            context_instance=RequestContext(request))
Example #7
0
def project_version(request, project_slug, modi_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    modifier = get_object_or_404(models.Version, slug=modi_slug)
    modifier_type = "Version"
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/modifier_view.html", locals(),
            context_instance=RequestContext(request))
Example #8
0
def view_profile(request, username):
    user = User.objects.get(username=username)
    profile = user.userprofile
    assigned_issues = []
    created_issues = []
    for x in profile.issue_set.all():
        can_view, can_edit, can_comment = utils.check_perms(request, x.project)
        if can_view:
            assigned_issues.append(x.id)

    for x in profile.issue_creator.all():
        can_view, can_edit, can_comment = utils.check_perms(request, x.project)
        if can_view:
            created_issues.append(x.id)

    assigned = models.Issue.objects.filter(id__in=assigned_issues)
    created = models.Issue.objects.filter(id__in=created_issues)

    return render_to_response(
        "djtracker/user_profile.html", locals(),
        context_instance=RequestContext(request))
Example #9
0
def view_category(request, cat_slug):
    category = get_object_or_404(models.Category, slug=cat_slug)
    project_ids = []
    for x in category.project_set.all():
        can_view, can_edit, can_comment = utils.check_perms(request, x)
        if can_view:
            project_ids.append(x.id)

    project_list = models.Project.objects.filter(id__in=project_ids)
    return render_to_response(
        "djtracker/index.html", locals(),
        context_instance=RequestContext(request))
Example #10
0
def get_allowed_project_ids(request, user=None, permission='view'):
    """
    returns a list of project ids which request.user is allowed to see 
    """    
    project_ids = []
    perm_index = ['view', 'edit', 'comment'].index(permission)    
    # need to reference Project indirectly to avoid circular import reference
    for project in models.get_model('djtracker','project').objects.all():
        perms = check_perms(request, project, user)
        if perms[perm_index]:
            project_ids.append(project.id)
    return project_ids
Example #11
0
def view_profile(request, username):
    user = User.objects.get(username=username)
    profile = user.userprofile
    assigned_issues = []
    created_issues = []
    for x in profile.issue_set.all():
        can_view, can_edit, can_comment = utils.check_perms(request, x.project)
        if can_view:
            assigned_issues.append(x.id)

    for x in profile.issue_creator.all():
        can_view, can_edit, can_comment = utils.check_perms(request, x.project)
        if can_view:
            created_issues.append(x.id)

    assigned = models.Issue.objects.filter(id__in=assigned_issues)
    created = models.Issue.objects.filter(id__in=created_issues)

    return render_to_response(
        "djtracker/user_profile.html", locals(),
        context_instance=RequestContext(request))
Example #12
0
def get_allowed_project_ids(request, user=None, permission='view'):
    """
    returns a list of project ids which request.user is allowed to see 
    """
    project_ids = []
    perm_index = ['view', 'edit', 'comment'].index(permission)
    # need to reference Project indirectly to avoid circular import reference
    for project in models.get_model('djtracker', 'project').objects.all():
        perms = check_perms(request, project, user)
        if perms[perm_index]:
            project_ids.append(project.id)
    return project_ids
Example #13
0
def project_type_issues(request, project_slug, type_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issues = project.issue_set.filter(issue_type__slug=type_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    status_choices = models.Status.objects.all()
    priority_choices = models.Priority.objects.all()
    type_choices = models.IssueType.objects.all()
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_view_all.html", locals(),
            context_instance=RequestContext(request))        
Example #14
0
def project_status_issues(request, project_slug, status_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issues = project.issue_set.filter(status__slug=status_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    status_choices = models.Status.objects.all()
    priority_choices = models.Priority.objects.all()
    type_choices = models.IssueType.objects.all()
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_view_all.html", locals(),
            context_instance=RequestContext(request))        
Example #15
0
def project_index(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    open_issues = project.issue_set.filter(status__slug="open")
    priorities = models.Priority.objects.all()
    statuses = models.Status.objects.all()
    types = models.IssueType.objects.all()
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    
    ## Check if we're watching this project
    is_watching = False
    if request.user.is_authenticated():
        try:
            profile = models.UserProfile.objects.get(user=request.user)
        except ObjectDoesNotExist:
            is_watching = False
            profile = None
        if profile in project.watched_by.all():
            is_watching = True
    
    if "watch" in request.GET and can_view:
        if request.GET['watch'] == "yes":
            try:
                profile = models.UserProfile.objects.get(user=request.user)
            except ObjectDoesNotExist:
                profile = models.UserProfile.create(user=request.user)
                profile.save()
            project.watched_by.add(profile)
            return HttpResponseRedirect(project.get_absolute_url())
        elif request.GET['watch'] == "no":
            profile = models.UserProfile.objects.get(user=request.user)
            project.watched_by.remove(profile)
            return HttpResponseRedirect(project.get_absolute_url())
        
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return list_detail.object_detail(request,
            queryset=models.Project.objects.all(),
            extra_context={'can_comment': can_comment,
                'open_issues': open_issues[:5],
                'statuses': statuses,
                'priorities': priorities,
                'request': request,
                'types': types,
                'is_watching': is_watching
            },
            slug=project_slug,
            template_name="djtracker/project_index.html",
            template_object_name="project"
        )
Example #16
0
def project_index(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    open_issues = project.issue_set.filter(status__slug="open")
    priorities = models.Priority.objects.all()
    statuses = models.Status.objects.all()
    types = models.IssueType.objects.all()
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    
    ## Check if we're watching this project
    is_watching = False
    if request.user.is_authenticated():
        try:
            profile = models.UserProfile.objects.get(user=request.user)
        except ObjectDoesNotExist:
            is_watching = False
            profile = None
        if profile in project.watched_by.all():
            is_watching = True
    
    if "watch" in request.GET and can_view:
        if request.GET['watch'] == "yes":
            try:
                profile = models.UserProfile.objects.get(user=request.user)
            except ObjectDoesNotExist:
                profile = models.UserProfile.create(user=request.user)
                profile.save()
            project.watched_by.add(profile)
            return HttpResponseRedirect(project.get_absolute_url())
        elif request.GET['watch'] == "no":
            profile = models.UserProfile.objects.get(user=request.user)
            project.watched_by.remove(profile)
            return HttpResponseRedirect(project.get_absolute_url())
        
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return list_detail.object_detail(request,
            queryset=models.Project.objects.all(),
            extra_context={'can_comment': can_comment,
                'open_issues': open_issues[:5],
                'statuses': statuses,
                'priorities': priorities,
                'request': request,
                'types': types,
                'is_watching': is_watching
            },
            slug=project_slug,
            template_name="djtracker/project_index.html",
            template_object_name="project"
        )
Example #17
0
def project_index(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    open_issues = project.issue_set.filter(status="Open")
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    if can_view is False:
        return HttpResponseNotFound()
    else:
        return list_detail.object_detail(request,
            queryset=models.Project.objects.all(),
            extra_context={'can_comment': can_comment,
                'open_issues': open_issues[:5]},
            slug=project_slug,
            template_name="djtracker/project_index.html",
            template_object_name="project"
        )
Example #18
0
def project_all_issues(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issues = project.issue_set.all()
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    status_choices = models.Status.objects.all()
    priority_choices = models.Priority.objects.all()
    type_choices = models.IssueType.objects.all()
    if 'component' in request.GET:
        if request.GET.get('component'):
            issues = issues.filter(component__slug=request.GET.get('component'))
    if 'version' in request.GET:
        if request.GET.get('version'):
            issues = issues.filter(version__slug=request.GET.get('version'))
    if 'milestone' in request.GET:
        if request.GET.get('milestone'):
            issues = issues.filter(milestone__slug=request.GET.get('milestone'))
    if 'status' in request.GET:
        if request.GET.get('status'):
            issues = issues.filter(status__slug=request.GET.get('status'))
    if 'type' in request.GET:
        if request.GET.get('type'):
            issues = issues.filter(issue_type__slug=request.GET.get('type'))
    if 'priority' in request.GET:
        if request.GET.get('priority'):
            issues = issues.filter(priority__slug=request.GET.get('priority'))
    if 'save' in request.GET:
        if request.GET.get('priority') and request.GET.get('savename'):
            filter = models.IssueFilter()
            filter.name = request.GET.get('savename')
            filter.component = request.GET.get('component')
            filter.version = request.GET.get('version')
            filter.milestone = request.GET.get('milestone')
            filter.status = request.GET.get('status')
            filter.type = request.GET.get('type')
            filter.priority = request.GET.get('priority')
            filter.project = project
            if request.user.is_authenticated():
                filter.user = request.user.userprofile
            filter.save()

    if can_view is False:
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_view_all.html", locals(),
            context_instance=RequestContext(request))
Example #19
0
def index(request):
    projects = models.Project.objects.filter(active=True)
    viewable_projects = []
    for x in projects:
        can_view, can_edit, can_comment = utils.check_perms(request, x)
        if can_view:
            viewable_projects.append(x.id)

    display_projects = models.Project.objects.filter(id__in=viewable_projects)

    return list_detail.object_list(request,
        queryset=display_projects,
        extra_context={'user': request.user, 'request': request},
        paginate_by=10,
        allow_empty=True,
        template_name="djtracker/index.html",
        template_object_name="project"
    )
Example #20
0
def index(request):
    projects = models.Project.objects.filter(active=True)
    viewable_projects = []
    for x in projects:
        can_view, can_edit, can_comment = utils.check_perms(request, x)
        if can_view:
            viewable_projects.append(x.id)

    display_projects = models.Project.objects.filter(id__in=viewable_projects)

    return list_detail.object_list(request,
        queryset=display_projects,
        extra_context={'user': request.user, 'request': request},
        paginate_by=10,
        allow_empty=True,
        template_name="djtracker/index.html",
        template_object_name="project"
    )
Example #21
0
def modify_issue(request, project_slug, issue_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, slug=issue_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)    
    if can_edit is False:
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.IssueForm(project.id, can_edit, request.POST, instance=issue)
            if form.is_valid():
                issue=form.save()
                return HttpResponseRedirect(issue.get_absolute_url())
        else:
            form = forms.IssueForm(project.id, can_edit, instance=issue)
        
        return render_to_response(
            "djtracker/modify_issue.html", locals(),
            context_instance=RequestContext(request))
Example #22
0
def modify_issue(request, project_slug, issue_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, id=issue_id)
    can_view, can_edit, can_comment = utils.check_perms(request, project)    
    if can_edit is False:
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.IssueForm(project.id, can_edit, request.POST, instance=issue)
            if form.is_valid():
                issue=form.save()
                return HttpResponseRedirect(issue.get_absolute_url())
        else:
            form = forms.IssueForm(project.id, can_edit, instance=issue)
        
        return render_to_response(
            "djtracker/modify_issue.html", locals(),
            context_instance=RequestContext(request))
Example #23
0
def view_issue(request, project_slug, issue_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, slug=issue_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)

    ## Check if we're watching
    is_watching = False
    if request.user.is_authenticated():
        try:
            profile = models.UserProfile.objects.get(user=request.user)
        except ObjectDoesNotExist:
            is_watching = False
            profile = None
        if profile in issue.watched_by.all():
            is_watching = True

    ## Check for GET variables
    if "watch" in request.GET and can_view:
        if request.GET['watch'] == "yes":
            try:
                profile = models.UserProfile.objects.get(user=request.user)
            except ObjectDoesNotExist:
                profile = models.UserProfile.create(user=request.user)
                profile.save()
            issue.watched_by.add(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.slug])
            )
        elif request.GET['watch'] == "no":
            profile = models.UserProfile.objects.get(user=request.user)
            issue.watched_by.remove(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.slug])
            )
                
    ## Check if we can view
    if can_view is False: 
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_detail.html", locals(),
            context_instance=RequestContext(request))
Example #24
0
def view_issue(request, project_slug, issue_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, id=issue_id)
    can_view, can_edit, can_comment = utils.check_perms(request, project)

    ## Check if we're watching
    is_watching = False
    if request.user.is_authenticated():
        try:
            profile = models.UserProfile.objects.get(user=request.user)
        except ObjectDoesNotExist:
            is_watching = False
            profile = None
        if profile in issue.watched_by.all():
            is_watching = True

    ## Check for GET variables
    if "watch" in request.GET and can_view:
        if request.GET['watch'] == "yes":
            try:
                profile = models.UserProfile.objects.get(user=request.user)
            except ObjectDoesNotExist:
                profile = models.UserProfile.create(user=request.user)
                profile.save()
            issue.watched_by.add(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.id])
            )
        elif request.GET['watch'] == "no":
            profile = models.UserProfile.objects.get(user=request.user)
            issue.watched_by.remove(profile)
            return HttpResponseRedirect(
                reverse("project_issue", args=[project.slug, issue.id])
            )
                
    ## Check if we can view
    if can_view is False: 
        return HttpResponseNotFound()
    else:
        return render_to_response(
            "djtracker/issue_detail.html", locals(),
            context_instance=RequestContext(request))
Example #25
0
def issue_attach(request, project_slug, issue_id):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, id=issue_id)
    can_view, can_edit, can_comment = utils.check_perms(request, project)

    if can_view is False or can_comment is False: 
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.FileUploadForm(request.POST, request.FILES)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    issue.get_absolute_url()
                )
        else:
            form = forms.FileUploadForm(initial={'issue': issue.id})
    return render_to_response(
        "djtracker/upload_form.html", locals(),
        context_instance=RequestContext(request))
Example #26
0
def issue_attach(request, project_slug, issue_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    issue = get_object_or_404(models.Issue, slug=issue_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)

    if can_view is False or can_comment is False: 
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.FileUploadForm(request.POST, request.FILES)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    issue.get_absolute_url()
                )
        else:
            form = forms.FileUploadForm(initial={'issue': issue.id})
    return render_to_response(
        "djtracker/upload_form.html", locals(),
        context_instance=RequestContext(request))
Example #27
0
def submit_issue(request, project_slug):
    project = get_object_or_404(models.Project, slug=project_slug)
    can_view, can_edit, can_comment = utils.check_perms(request, project)
    status_open = models.Status.objects.get(slug="open")
    priority_normal = models.Priority.objects.get(slug="normal")
    if request.user.id:
        try:
            profile = request.user.userprofile
            profile_id = profile.id
        except AttributeError:
            profile_id = None
    else:
        profile_id = None
    if can_comment is False:
        return HttpResponseNotFound()
    else:
        if request.method == "POST":
            form = forms.IssueForm(project.id, can_edit, request.POST)
            if form.is_valid():
                issue = form.save()
                return HttpResponseRedirect(issue.get_absolute_url())
        else:
            if request.user.is_authenticated():
                form = forms.IssueForm(project.id, can_edit, 
                    initial={ 'project': project.id, 'created_by': profile_id,
                              'status': status_open.id, 
                              'priority': priority_normal.id
                            }
                )
            else:
                form = forms.IssueForm(project.id, can_edit,
                    initial={ 'project': project.id,
                              'status': status_open.id, 
                              'priority': priority_normal.id 
                    }
                )
        return render_to_response(
            "djtracker/submit_issue.html", locals(),
            context_instance=RequestContext(request))
Example #28
0
    def render(self, context):
        try:
            request = resolve_variable('request', context)
        except:
            request = None
        try:
            model = get_model(self.app_name, self.model_name)
        except:
            raise TemplateSyntaxError, "Failed to retrieve model"

        object_list = model.objects.all()
        object_list = object_list.order_by(self.sort)
        if object_list.count() > self.count:
            object_list = object_list[:self.count]
        project_ids = []
        for x in object_list:
            if hasattr(x, "allow_anon_viewing") and request:
                can_view, can_edit, can_comment = utils.check_perms(request, x)
                if can_view:
                    project_ids.append(x.id)
                    object_list = model.objects.filter(id__in=project_ids)
        context.update({self.var_name: object_list})
        return ''