Commit bbdf0bf4 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Firt version of the web2py template application.

parents
.project
.pydevproject
.settings/
cache/
cron/
databases/
errors/
private/
sessions/
static/plugin_dbui/
static/plugin_mathjax/
uploads/
""" Controllers """
def index():
"""Main Controller to run the application launching the plugin dbui.
"""
return LOAD('plugin_dbui', 'index', vars=request.vars)
""" $Id$ """
def index():
"""Main Controller handling report.
"""
return 'Report section'
def report_1():
"""First trial
"""
# Resolve foreign key
query = db.publications.id_collaborations == db.collaborations.id
query = (query) & (db.publications.id_publishers == db.publishers.id)
query = (query) & (db.publications.id_categories_aeres == db.categories_aeres.id)
# publication with comite de lecture
query = (query) & (db.publications.conference_title == '')
query = (query) & ((db.categories_aeres.code == 'ACL') | (db.categories_aeres.code == 'ACLN'))
# Interrogate the database
rows = db(query).select(db.publications.title,
db.publications.authors,
db.publications.id_collaborations,
db.collaborations.collaboration,
db.publishers.abbreviation,
db.publications.year,
db.publications.doi,
db.publications.volume,
db.publications.first_page,
db.publications.last_page,
db.publications.conference_title,
db.categories_aeres.code)
return {'title': 'Rapport 1', 'publis': rows}
def report_2():
""" Test jsmath on a standalone page
"""
return {}
# coding: utf8
# French translation
{
}
# -*- coding: utf-8 -*-
""" db_database
Defined the tables for your applications.
Initialized the web2py-dbui plugins
"""
from datetime import datetime
from gluon.tools import PluginManager
#-------------------------------------------------------------------------------
#
# languages parameters
#
#-------------------------------------------------------------------------------
T.lazy = False # immediate translation
T.set_current_languages('en', 'en-gb', 'en-us') # mother tongue
T.force('fr-fr') # user language
#-------------------------------------------------------------------------------
#
# dbui_plugins parameters
#
#-------------------------------------------------------------------------------
#plugins = PluginManager()
#plugins.dbui.script_path = 'static/scripts'
#plugins.dbui.page_view = 'plugin_dbui.html'
#-------------------------------------------------------------------------------
#
# connection to the database
#
#-------------------------------------------------------------------------------
db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB
#-------------------------------------------------------------------------------
#
# define tables
#
#-------------------------------------------------------------------------------
db.define_table("categories_aeres",
Field("code", "string", notnull=True, unique=True),
Field("definition", "text", notnull=True))
db.define_table("collaborations",
Field("collaboration", "string", notnull=True, unique=True))
db.define_table("countries",
Field("country", "string", notnull=True, unique=True),
Field("abbreviation", "string", notnull=True))
db.define_table("projects",
Field("project", "string", notnull=True, unique=True))
db.define_table("publishers",
Field("publisher", "string", notnull=True, unique=True),
Field("abbreviation", "string", notnull=True))
db.define_table("reports",
Field("type", "string", notnull=True, unique=True))
db.define_table("teams",
Field("team", "string", notnull=True, unique=True))
#-------------------------------------------------------------------------------
#
# Publications table
# the main table of this application
# Create at the end since its depends on the other tables
#
#-------------------------------------------------------------------------------
year = datetime.now().year
#
# tooltips
#
tp_authors = \
"""List of authors separated by commma: J. Doe, P.-Y. Smith
For large collaboration the first author followed by et al.: J. Doe et al."""
tp_authors_cppm = \
"""List of authors separated by comma: P.-Y. Doe, J. Smith"""
tp_report_numbers = \
"""List of report identifier separated by comma:
LHCb-PROC-2008-04, arXiv:0906.1516 """
tp_speaker = \
"""The name of the speaker: P.-Y. Smith"""
#
# the table
#
db.define_table("publications",
Field("title", "text", notnull=True),
Field("authors", "string", notnull=True, comment=tp_authors),
Field("id_collaborations", db.collaborations, default=1, label="Collaboration"),
Field("id_publishers", db.publishers, default=1, label="Publisher"),
Field("year", "integer", notnull=True, default=year, requires=IS_INT_IN_RANGE(1900, year+1)),
Field("doi", "string"),
Field("volume", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))),
Field("first_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))),
Field("last_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))),
Field("e_print", "string", requires=IS_EMPTY_OR(IS_URL())),
Field("conference_title", "text", label='Title'),
Field("conference_url", "string", label='url', requires=IS_EMPTY_OR(IS_URL())),
Field("conference_start", "date", label='Start date'),
Field("conference_end", "date", label='End date'),
Field("conference_town", "string", label='Town'),
Field("id_countries", db.countries, default=1, label='Country'),
Field("conference_speaker", "string", label='Speaker', comment=tp_speaker),
Field("report_numbers", "string", comment=tp_report_numbers),
Field("id_reports", db.reports, default=1, label="Report type"),
Field("authors_cppm", "text", notnull=True, comment=tp_authors_cppm),
Field("id_teams", db.teams, default=1, label='Team'),
Field("id_projects", db.projects, default=1, label='Projects'),
Field("id_categories_aeres", db.categories_aeres, default=1, label='AERES'))
#
# define foreign keys
#
db.publications.id_categories_aeres.requires = \
IS_IN_DB(db, 'categories_aeres.id', 'categories_aeres.code')
db.publications.id_collaborations.requires = \
IS_IN_DB(db, 'collaborations.id', 'collaborations.collaboration')
db.publications.id_countries.requires = \
IS_IN_DB(db, 'countries.id', 'countries.country')
db.publications.id_publishers.requires = \
IS_IN_DB(db, 'publishers.id', 'publishers.abbreviation')
db.publications.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.publications.id_reports.requires = \
IS_IN_DB(db, 'reports.id', 'reports.type')
db.publications.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
# -*- coding: utf-8 -*-
""" db_insert
Insert defaults values in the tables
"""
if not db(db.categories_aeres.id).count():
db.categories_aeres.insert(id=1, code= T('undefined'), definition=T('undefined'))
if not db(db.collaborations.id).count():
db.collaborations.insert(id=1, collaboration=T('undefined'))
if not db(db.countries.id).count():
db.countries.insert(id=1, country=T('undefined'), abbreviation=T('undefined'))
if not db(db.projects.id).count():
db.projects.insert(id=1, project=T('undefined'))
if not db(db.publishers.id).count():
db.publishers.insert(id=1, publisher=T('undefined'), abbreviation=T('undefined'))
if not db(db.reports.id).count():
db.reports.insert(id=1, type=T('undefined'))
if not db(db.teams.id).count():
db.teams.insert(id=1, team=T('undefined'))
\ No newline at end of file
# -*- coding: utf-8 -*-
""" db_widgets
Customize forms and grids widgets
"""
from datetime import datetime
dbui = local_import('plugin_dbui')
#
# Customize the main viewport
# hide some tables depending on the user role
#
#vm = dbui.ViewportModifier()
#vm.hide_tables('publishers',
# 'categories_aeres',
# 'categories_commission',
# 'collaborations',
# 'countries',
# 'teams',
# 'projects',
# 'publishers')
#
#vm.hide_form_node()
#vm.set_grid_node_name('View')
#
#
# add plugin to all grids
#
dbui.configure_grids(db, plugins=['RowEditor',
'RowEditorContextMenu',
'pGridPaging',
# 'pGridMathJax'
])
#
# Create composite fields for the publication form
#
fieldsModifier = dbui.FieldsModifier('publications')
fieldsModifier.configure_field('year',
maxValue=datetime.now().year)
fieldsModifier.merge_fields('first_page',
'last_page',
fieldLabel=T('Pages'),
fieldDefaults={'hideLabel': True, 'flex': 1},
layout='hbox')
fieldsModifier.merge_fields('conference_start',
'conference_end',
fieldLabel=T('Dates'),
fieldDefaults={'hideLabel': True, 'flex': 1},
layout='hbox')
#
# Create fieldSet for the publication form
#
formModifier = dbui.FormModifier('publications')
formModifier.merge_fields('title',
'authors',
'id_collaborations',
'id_publishers',
'year',
'doi',
'volume',
'first_page',
'e_print',
title=T('General'),
flex=1)
formModifier.merge_fields('conference_title',
'conference_url',
'conference_start',
'conference_town',
'id_countries',
'conference_speaker',
dbui.Spacer(height=80),
title=T('Conference'),
flex=1)
formModifier.merge_fields('authors_cppm',
'id_teams',
'id_projects',
'id_categories_aeres',
dbui.Spacer(height=140),
title='CPPM',
flex=1)
formModifier.merge_fields('report_numbers',
'id_reports',
dbui.Spacer(height=237),
title=T('Report'),
flex=1)
#
# Organize fieldSet within a TabPanel embedded in the publication form
#
formModifier.set_mapper(dbui.map_tabpanel)
#
# Polish the look and feel of the publication form
# NOTE: the width/height define the size of the window
# when running the form from the grid. The defaults defines the height
# of the fieldSet allowing a fine tuning of the form layout.
#
formModifier.configure(buttonAlign='right',
labelWidth=100,
labelAlign='right',
width=400,
height=400,
defaults={'height': 350})
#
# Define a column template for the publications grid
#
tpl = ['<b>{PublicationsTitle}</b><br>',
'{PublicationsAuthors}',
'<tpl if="PublicationsId_collaborations &gt; 1">, {CollaborationsCollaboration}</tpl>',
'<tpl if="PublicationsDoi"><br>{PublicationsDoi}</tpl>',
'<tpl if="PublicationsId_publishers &gt; 1"><br>{PublishersAbbreviation}',
'<tpl if="PublicationsVolume"> {PublicationsVolume}</tpl>',
'<tpl if="PublicationsYear"> ({PublicationsYear}) </tpl>',
'<tpl if="PublicationsFirst_page"> {PublicationsFirst_page}</tpl>',
'<tpl if="PublicationsLast_page">-{PublicationsLast_page}</tpl>',
'</tpl>',
'<tpl if="PublicationsE_print"><br>{PublicationsE_print}</tpl>',
'<tpl if="PublicationsConference_title"><br><br>{PublicationsConference_title}',
'<tpl if="PublicationsConference_town"><br>{PublicationsConference_town}</tpl>',
'<tpl if="CountriesCountry">, {CountriesCountry}</tpl>',
'<tpl if="PublicationsConference_start">, {PublicationsConference_start}</tpl>',
'<tpl if="PublicationsConference_end"> - {PublicationsConference_end}</tpl>',
'<tpl if="PublicationsConference_url"><br>{PublicationsConference_url}</tpl>',
'<br>%s: {PublicationsConference_speaker}' % T('Speaker'),
'</tpl>',
'<tpl if="PublicationsReport_numbers"><br><br>',
'<tpl if="PublicationsId_reports &gt; 1">{ReportsType}, </tpl>',
'{PublicationsReport_numbers}',
'</tpl>',
'<br>Auteurs CPPM : {PublicationsAuthors_cppm}'
]
gridModifier = dbui.GridModifier('publications')
gridModifier.merge_columns('title',
'authors',
'id_collaborations',
'id_publishers',
'doi',
'volume',
'first_page',
'last_page',
'e_print',
'conference_title',
'conference_url',
'conference_start',
'conference_end',
'conference_town',
'id_countries',
'conference_speaker',
'report_numbers',
'id_reports',
'authors_cppm',
autohide=True,
flex=1,
header=T('Publication'),
position=0,
tpl=tpl)
#
# Setup a filter panel for the publication grid
#
filters = [('year', '==', T('select publication for a given year')),
('id_teams', '==', T('select publications for a given team')),
('id_projects', '==', T('select publications for a given project')),
('id_categories_aeres', '==', T('select publications with a given AERES code')),
('authors_cppm', 'contains', T('select publications for a given CPPM author')),
]
gridModifier.set_filters(*filters, width=300)
/**
* combo_1.js
*
* To test and debug combo widget with a local store.
* $Id$
*
*/
Ext.onReady(function(){
Ext.QuickTips.init();
var store = new Ext.data.JsonStore({
fields: ['id', 'idcategory', 'category'],
data: [
{id: 1, idcategory: 10, category: 'database'},
{id: 2, idcategory: 11, category: 'development'},
{id: 3, idcategory: 12, category: 'emulator'},
{id: 4, idcategory: 13, category: 'system'}
]
});
var combo = new Ext.form.ComboBox({
selectOnFocus: true,
triggerAction: 'all',
typeAhead: true,
displayField: "category",
fieldLabel: "Category",
valueField: "id",
hiddenName: "idcategory",
emptyText: "Select a category... ",
mode: 'local',
store: store,
});
combo.on("select", function(){
console.log(this.getValue());
});
combo.on('render', function(c){
new Ext.ToolTip({
target: c.getEl(),
anchor: 'right',
trackMouse: true,
html: 'Tracking while you move the mouse'
});
});
var panel = new Ext.Panel({
renderTo: "appmain",
bodyStyle: 'padding:5px 5px 0',
height: 50,
width: 350,
frame: true,
labelWidth: 75,
items: [combo],
});
// // select a value
// combo.setValue(2);
});
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>{{=title}}</title>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_mathjax/MathJax.js"></script>
</head>
<body>
<h2>Publications avec comité de lecture</h2>
<ol>
{{for el in publis:}}
<li>
{{=el.publications.title}}<br>
{{=el.publications.authors}}
{{if el.publications.id_collaborations > 1:}}, {{=el.collaborations.collaboration}},{{pass}}<br>
{{if el.publishers.abbreviation:}}{{=el.publishers.abbreviation}}{{pass}}
{{if el.publications.volume:}}{{=el.publications.volume}}{{pass}}
{{if el.publications.year:}}({{=el.publications.year}}){{pass}}
{{if el.publications.first_page:}}{{=el.publications.first_page}}{{pass}}
{{if el.publications.last_page:}}- {{=el.publications.last_page}}{{pass}}
</li>
{{pass}}
</ol>
</body>
</html>
Markdown is supported
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