Beispiel #1
0
def user_publications(request):
    context = {}
    context["publications"] = []
    pubs = Publication.objects.filter(added_by_username=request.user.username)
    for pub in pubs:
        project = ProjectAllocationMapper.get_publication_project(pub)
        if project:
            context["publications"].append(
                {
                    "title": pub.title,
                    "author": pub.author,
                    "abstract": pub.abstract,
                    "nickname": project.nickname,
                    "chargeCode": project.charge_code,
                }
            )
    return render(request, "projects/view_publications.html", context)
Beispiel #2
0
def user_publications(request):
    context = {}
    if "del_pub" in request.POST:
        try:
            del_pub_id = request.POST["pub_ref"]
            logger.debug("deleting publication with id {}".format(del_pub_id))
            Publication.objects.get(pk=del_pub_id).delete()
        except Exception:
            logger.exception("Failed removing publication")
            messages.error(
                request,
                "An unexpected error occurred while attempting "
                "to remove this publication. Please try again",
            )
    context["publications"] = []
    pubs = Publication.objects.filter(added_by_username=request.user.username)
    for pub in pubs:
        project = ProjectAllocationMapper.get_publication_project(pub)
        if project:
            context["publications"].append(
                {
                    "id": pub.id,
                    "title": pub.title,
                    "author": pub.author,
                    "link": "" if not pub.link else pub.link,
                    "forum": pub.forum,
                    "month": ""
                    if not pub.month
                    else datetime.datetime.strptime(str(pub.month), "%m").strftime(
                        "%b"
                    ),
                    "year": pub.year,
                    "nickname": project.nickname,
                    "chargeCode": project.charge_code,
                }
            )
    return render(request, "projects/view_publications.html", context)