Ejemplo n.º 1
0
    def _key_needed(request):
        proposals = get_proposals(request)
        project = request.user.get_current_project(proposals)

        if not project.encrypted:
            return False

        return not project.has_encryption_key()
Ejemplo n.º 2
0
def set_current(request, id):
    proj = UserProject.get_project(get_proposals(request), id)
    if proj is None:
        return HttpResponseNotFound()

    request.user.set_current_project(proj)

    # redirect to the 'landing page' page
    return redirect(reverse("project_summary"))
Ejemplo n.º 3
0
    def check_current_project(request):
        if _is_excluded_url(request.path_info):
            return get_response(request)

        proposals = get_proposals(request)
        current_project = request.user.get_current_project(proposals)
        if current_project is None:
            return redirect(_get_redirect_url(request))

        return get_response(request)
Ejemplo n.º 4
0
def projects(request):
    """
    Adds a projects related data to template context.
    """
    if not request.user.is_authenticated:
        # user not logged in, no projects context
        return {}

    proposals = get_proposals(request)

    return {
        # list of all projects that are accessible to the user
        "projects": list(UserProject.user_projects(proposals)),
        # user's currently selected project
        "project": request.user.get_current_project(proposals),
    }
Ejemplo n.º 5
0
def new(request):
    """
    GET requests show the 'Create new Project' page
    POST requests will try to create a new project
    """

    if request.method == "GET":
        proposals = sorted(get_proposals(request), reverse=True)
        return render(
            request,
            "project_new.html",
            {"proposals": proposals},
        )

    #
    # HZB-site hack, use 'username' as proposal
    #
    # As HZB is not using proposal to organize data, use the
    # user name as 'proposal' for now. Perhaps we should
    # restructure the code to no use 'proposal' concept in general.
    #
    post_args = request.POST
    if current.proposals_disabled():
        # make a mutable copy of POST arguments dict
        post_args = post_args.copy()
        # put down current user name as 'proposal'
        post_args["proposal"] = request.user.username

    form = ProjectForm(post_args, request.FILES)
    if not form.is_valid():
        return HttpResponseBadRequest(form.get_error_message())

    protein, proposal, crystals, import_autoproc, encrypt = form.get_values()
    proj = UserProject.create_new(protein, proposal)

    setup_project.delay(str(proj.id), protein, proposal, crystals.as_list(),
                        import_autoproc, encrypt)

    return HttpResponse("ok")
Ejemplo n.º 6
0
def have_pending_projects(request):
    proposals = get_proposals(request)
    return request.user.have_pending_projects(proposals)
Ejemplo n.º 7
0
def current_project(request) -> Project:
    proposals = get_proposals(request)
    return request.user.get_current_project(proposals)
Ejemplo n.º 8
0
def _wrap_projects(request):
    for project in UserProject.user_projects(get_proposals(request)):
        yield ProjectEntry(project)