Commit 3a5b5d4b authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Populating the page displayed after a successful submission

parent 23fc4050
Pipeline #9803 passed with stage
in 10 minutes and 19 seconds
......@@ -122,7 +122,23 @@ class Bibliography(AutoFillableModel):
return True
class Meta:
verbose_name_plural = "bibliographies"
verbose_name_plural = "Bibliographies"
verbose_name = "Bibliography"
def data_and_study(self):
ret = []
for f in [
"cytotox",
"xray",
"in_silico",
"in_vitro",
"in_cellulo",
"in_vivo",
"pharmacokinetic",
]:
if getattr(self, f, False):
ret.append(self._meta.get_field(f).verbose_name.title())
return ", ".join(ret)
def __str__(self):
return '{}, {}'.format(self.source, self.id_source)
......@@ -1204,6 +1220,8 @@ class RefCompoundBiblio(models.Model):
class Meta:
unique_together = (('compound', 'bibliography'),)
verbose_name_plural = "Compounds in bibliography"
verbose_name = "Compound in bibliography"
def __str__(self):
return 'Ref. {} on {}'.format(self.bibliography, self.compound)
......
......@@ -27,7 +27,7 @@
<nav class="breadcrumb breadNav" role="navigation">
<div class="breadNav-label">You are here</div>
<div aria-labelledby="breadNav-label">
{% block breadcrumb %}{{block.super}}{% trans 'Admin_session_title' %}{% endblock %}
{% block breadcrumb %}{{block.super}}<a href="{% url 'admin-session'%}" class="breadNav-link">{% trans 'Admin_session_title' %}</a>{% endblock %}
</div>
</nav>
<div id="main-wrapper" class="page">
......
{% extends "admin-session.html" %}
{% load i18n %}
{% load static %}
{% load customtags %}
{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %}
{% block content%}
<div class="inner-wrap">
<nav class="breadcrumb breadNav" role="navigation">
<div class="breadNav-label">You are here</div>
<div aria-labelledby="breadNav-label">
{% block breadcrumb %}{{block.super}} > View
contribution {% endblock %}
</div>
</nav>
<div id="main-wrapper" class="page">
<div id="main">
<div id="content" class="main-content">
<div class="section row">
{% include "ippidb/bibliography_card.html" with object=bibliography css_class="col-xs-12 col-md-6"%}
{% include "ippidb/ppi_card.html" with object=ppi css_class="col-xs-12 col-md-6" %}
<div class="col-12">
<div class="card">
<h5 class="card-header">{{complexes|verbose_name}}</h5>
<div class="card-body">
{%for o in complexes%}
{{o}}
{%endfor%}
</div>
</div>
</div>
<div class="col-12">
<div class="card">
<h5 class="card-header">Tests</h5>
<div class="card-body">
{%for o in testactivitydescription%}
{% include "ippidb/testactivitydescription_card.html" with object=o %}
{%endfor%}
{%for o in testcytotoxdescription%}
{% include "ippidb/testcytotoxdescription_card.html" with object=o %}
{%endfor%}
{%for o in testpkdescription%}
{% include "ippidb/testpkdescription_card.html" with object=o %}
{%endfor%}
</div>
</div>
</div>
<div class="col-12">
<div class="card">
<h5 class="card-header">{{refcompoundbiblio|verbose_name}}</h5>
<div class="card-body">
{% include "ippidb/refcompoundbiblio_table.html" with objects=refcompoundbiblio %}
</div>
</div>
</div>
</div>
</div>
</div><!-- div main -->
</div>
</div>
{% endblock %}
{% extends "add.html" %}
{% load i18n %}
{% block form %}
<div id="Form">
<div class="last_step">
<div class="form_div">
CONGRATULATIONS!!! New publication added
</div>
<div class="add_new">
<a href="http://localhost:8000/admin-session/add/IdForm/">Add new content</a>
</div>
</div>
</div>
{% endblock %}
{% load customtags %}
{%if object%}
<div class="{{css_class}}">
<div class="card">
<h5 class="card-header">
{% if object.has_external_url %}
<a target="_blank"
href="{{ object.get_external_url }}">
{% endif %}
{{object.get_source_display}} <i>{{object.id_source}}</i>
{% if object.has_external_url %}
</a>
{% endif %}
<span class="float-right">{{object|verbose_name}}</span>
</h5>
<div class="card-body">
<b> {{object.title }}</b>
<br/>
<i>{{ object.authors_list }}</i><br/>
{{object.journal_name }} ({{object.biblio_year}})<br/>
Contains : {{object.data_and_study}}
</div>
</div>
</div>
{%endif%}
\ No newline at end of file
{% load customtags %}
{%if object%}
<div class="{{css_class}}">
<div class="card">
<h5 class="card-header">
{{object.pdb_id}}
<span class="float-right">{{object|verbose_name}}</span>
</h5>
<div class="card-body">
<table class="table table-sm table-striped">
<tbody>
<tr>
<th>{{object|verbose_name:'name'}}</th>
<td>{{object.name }}</td>
</tr>
<tr>
<th>{{object|verbose_name:'family'}}</th>
<td>{{object.family }}</td>
</tr>
<tr>
<th>{{object|verbose_name:'symmetry'}}</th>
<td>{{object.symmetry }}</td>
</tr>
<tr>
<th>{{object|verbose_name:'pockets_nb'}}</th>
<td>{{object.pockets_nb }}</td>
</tr>
<tr>
<th>{{object|verbose_name:'diseases'}}</th>
<td>
{%for d in object.diseases.all %}
{{d}}{%if not forloop.last%},{%endif%}
{%endfor %}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{%endif%}
\ No newline at end of file
{% load customtags %}
{%if objects and objects.exists%}
<table class="table">
<thead>
{%with sample=objects.first%}
<tr>
<th>{{sample|verbose_name:'compound_name'}}</th>
<th>{{sample.compound|verbose_name:'canonical_smile'}}</th>
<th>{{sample.compound|verbose_name:'iupac_name'}}</th>
<th><i class="fa fa-link"></i>
</tr>
{%endwith%}
</thead>
<tbody>
{%for o in objects%}
<tr>
<td>{{o.compound_name}}</td>
<td>{{o.compound.canonical_smile}}</td>
<td>{{o.compound.iupac_name}}</td>
<td>
<a target="_blank" href="{% url 'compound_card' pk=o.compound.pk %}"><i class="fa fa-link"></i></a>
</td>
</tr>
{%endfor%}
</tbody>
</table>
{%endif%}
\ No newline at end of file
{% load customtags %}
{%if object%}
<div class="card">
<h5 class="card-header">
{{object.test_name}}
<span class="float-right">{{object|verbose_name}}</span>
</h5>
<div class="card-body row">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'protein_domain_bound_complex'}}: </b>{{object.protein_domain_bound_complex}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'protein_bound_construct'}}: </b>{{object.protein_bound_construct}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'is_primary'}}: </b>{{object.is_primary}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'test_type'}}: </b>{{object.test_type}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'test_type'}}: </b>{{object.test_type}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'test_modulation_type'}}: </b>{{object.test_modulation_type}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'nb_active_compounds'}}: </b>{{object.nb_active_compounds}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<b>{{object|verbose_name:'cell_line'}}: </b>{{object.cell_line}}
</div>
</div>
</div>
{%endif%}
\ No newline at end of file
{% load customtags %}
{%if object%}
<div class="card">
<h5 class="card-header">
{{object.test_name}}
<span class="float-right">{{object|verbose_name}}</span>
</h5>
<div class="card-body">
TODO
</div>
</div>
{%endif%}
\ No newline at end of file
{% load customtags %}
{%if object%}
<div class="card">
<h5 class="card-header">
{{object.test_name}}
<span class="float-right">{{object|verbose_name}}</span>
</h5>
<div class="card-body">
TODO
</div>
</div>
{%endif%}
\ No newline at end of file
......@@ -3,6 +3,7 @@ import logging
from django import forms
from django import template
from django.contrib.messages.storage.base import Message
from django.db.models import QuerySet
from django.forms.utils import ErrorList, ErrorDict
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
......@@ -143,3 +144,12 @@ def bootstrap_core(object):
@register.filter('startswith')
def startswith(text, starts):
return text.startswith(starts)
@register.filter
def verbose_name(obj, field_name=None):
if isinstance(obj, QuerySet):
return obj.model._meta.verbose_name_plural
if field_name is None:
return obj._meta.verbose_name
return obj._meta.get_field(field_name).verbose_name.title()
......@@ -22,6 +22,9 @@ urlpatterns = [
url(r'^contribute$', views.adminSession, name='admin-session'),
url(r'^contribute/add/(?P<step>.+)/$', ippidb_wizard, name='ippidb_step'),
url(r'^contribute/add/$', ippidb_wizard, name='admin-session-add'),
url(r'^contribute/view/(?P<bibli_pk>\d+)-(?P<ppi_pk>\d+)/$', views.admin_session_view, name='admin-session-view'),
url(r'^contribute/view/(?P<bibli_pk>\d+)-/$', views.admin_session_view, {'ppi_pk': None}),
url(r'^contribute/view/-(?P<ppi_pk>\d+)/$', views.admin_session_view, {'bibli_pk': None}),
url(r'^contribute/update/$', views.update, name='admin-session-update'),
url(r'^utils/mol2smi$', views.convert_mol2smi, name='mol2smi'),
url(r'^utils/smi2mol$', views.convert_smi2mol, name='smi2mol'),
......
......@@ -114,7 +114,11 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
protein_subset_ids.append(complex_json["protein"].pk)
form.set_protein_subset_ids(protein_subset_ids)
if current_step in ["TestActivityDescriptionFormSet", "TestCytotoxDescriptionFormSet", "TestPKDescriptionFormSet"]:
if current_step in [
"TestActivityDescriptionFormSet",
"TestCytotoxDescriptionFormSet",
"TestPKDescriptionFormSet",
]:
compound_form = super().get_form(
'CompoundForm',
data=self.storage.get_step_data('CompoundForm')
......@@ -234,7 +238,7 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# Step 7 Compounds
compounds = dict()
created_compounds=0
created_compounds = 0
for f in form_dict["CompoundForm"]:
if not f.is_valid():
continue
......@@ -283,7 +287,7 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# We set the dicts to translates attributes into model
form_dict["TestCytotoxDescriptionFormSet"].set_compounds(compounds)
# We set the constants attributes among the instances to be created by the modelformset
form_dict["TestCytotoxDescriptionFormSet"].instance=bibliography
form_dict["TestCytotoxDescriptionFormSet"].instance = bibliography
form_dict["TestCytotoxDescriptionFormSet"].is_valid()
cytotox_tests = form_dict["TestCytotoxDescriptionFormSet"].save()
print("Step 8.2: %i cytotox tests and %i results" % (
......@@ -295,7 +299,7 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# We set the dicts to translates attributes into model
form_dict["TestPKDescriptionFormSet"].set_compounds(compounds)
# We set the constants attributes among the instances to be created by the modelformset
form_dict["TestPKDescriptionFormSet"].instance=bibliography
form_dict["TestPKDescriptionFormSet"].instance = bibliography
form_dict["TestPKDescriptionFormSet"].is_valid()
pk_tests = form_dict["TestPKDescriptionFormSet"].save()
print("Step 8.3: %i PK tests and %i results" % (
......@@ -306,6 +310,22 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# re-save the ppi to update its name
ppi.save()
super().done(form_list=form_list, **kwargs)
return render(self.request, 'done.html', {
'form_data': [form.cleaned_data for form in form_list],
})
return admin_session_view(self.request, bibliography.pk, ppi.pk)
def admin_session_view(request, bibli_pk, ppi_pk):
context = {}
if bibli_pk:
bibliography = models.Bibliography.objects.get(pk=bibli_pk)
context["bibliography"] = bibliography
context["testactivitydescription"] = bibliography.testactivitydescription_set.all()
context["testcytotoxdescription"] = bibliography.testcytotoxdescription_set.all()
context["testpkdescription"] = bibliography.testpkdescription_set.all()
context["refcompoundbiblio"] = bibliography.refcompoundbiblio_set.all()
if ppi_pk:
ppi = models.Ppi.objects.get(pk=ppi_pk)
context["ppi"] = ppi
context["complexes"] = ppi.ppicomplex_set.all()
return render(request, 'contribute-view.html', context=context)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment