Source

wdmmg / wdmmg / controllers / entry.py

import logging

from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect

from wdmmg.lib.base import BaseController, render
from wdmmg.lib.helpers import Page
from wdmmg.lib.helpers import dept_name_to_wdtk_identifier
from wdmmg import model

log = logging.getLogger(__name__)

class EntryController(BaseController):
    def index(self):
        query = model.Entry.find()
        c.page = Page(
            collection=query,
            page=int(request.params.get('page', 1)),
            items_per_page=c.items_per_page,
            item_count=query.count(),
        )
        return render('entry/index.html')

    def view(self, id=None):
        c.row = model.Entry.by_id(id)
        if not c.row:
            abort(404, 'Sorry, there is no entry with code %r'% id)
    
        c.desc = c.row.explain()
        c.id = c.row.get('_id')
        del c.row['_id']
        c.from_ = c.row.get('from')
        del c.row['from']
        c.to = c.row.get('to')
        del c.row['to']
        c.dataset = c.row.get('dataset')
        del c.row['dataset']
        c.currency = c.row.get('currency', c.dataset.get('currency')).upper()
        if c.row.get('currency'):
            del c.row['currency']
        c.amount = c.row.get('amount')
        del c.row['amount']
        c.time = c.row.get('time')
        del c.row['time']
        
        if 'departments' in c.dataset.get('name'):
            c.show_foi = True
        else:
            c.show_foi = False
        return render('entry/view.html')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.