Skip to content

Commit

Permalink
merge categories
Browse files Browse the repository at this point in the history
  • Loading branch information
withanage committed May 26, 2017
2 parents aa04916 + 9e87c0e commit 74c1e04
Show file tree
Hide file tree
Showing 18 changed files with 1,503 additions and 346 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.so
*.pyc
*.*~
*.ipynb

# Packages #
############
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ cache: pip
python:
- '2.7'
- 'pypy'
- '3.5'
- '3.5'

82 changes: 76 additions & 6 deletions controllers/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@

from ompdal import OMPDAL, OMPSettings, OMPItem
from ompformat import dateFromRow, seriesPositionCompare
from datetime import datetime

from ompsolr import OMPSOLR
from ompbrowse import Browser
import json
from datetime import datetime

def category():



ignored_submission_id = myconf.take('omp.ignore_submissions') if myconf.take(
'omp.ignore_submissions') else -1

Expand Down Expand Up @@ -114,10 +120,66 @@ def series():
return locals()



def search():
q = '{}'.format(request.vars.q) if request.vars.q else '*'


form = form = SQLFORM.factory(
Field("title"),
Field("press_id"),
formstyle='divs',
submit_button="Search",
)
if form.process().accepted:
title = form.vars.title

sort= ['title_de','title_en']
start= 0
rows =10
fq = {'title_en':'*','locale': 'de'}
exc = {'submission_id':'42'}
fl = ['title_de','submission_id','press_id','title_en']

if myconf.take("plugins.solr") == str(1):
solr = OMPSOLR(db,myconf)
#r = solr.si.query(solr.si.Q(title_en=title) | solr.si.Q(title_de=title))
#r = solr.si.query(solr.si.Q(title_de='*Leben*'))
r = solr.si.query(solr.si.Q(q.decode('utf-8')) & solr.si.Q(press_id=myconf.take('omp.press_id')) )
#for s in sort:
# r =r.sort_by(s)
#r = r.filter(**fq)
#r = r.exclude(**exc)
#r = r.field_limit(fl)
#r = r.highlight(q.keys())
r= r.paginate(start=start, rows=rows)
results = r.execute()
hl = results.highlighting

from paginate import Page, make_html_tag

def paginate_link_tag(item):
"""
Create an A-HREF tag that points to another page usable in paginate.
"""
a_tag = Page.default_link_tag(item)
if item['type'] == 'current_page':
return make_html_tag('li', a_tag, **{'class': 'active'})
return make_html_tag('li', a_tag)


p = Page(['test','test2'], page=15, items_per_page=15, item_count=10)

return locals()




def index():
ompdal = OMPDAL(db, myconf)

ompdal = OMPDAL(db, myconf)
press = ompdal.getPress(myconf.take('omp.press_id'))

if not press:
redirect(URL('home', 'index'))
press_settings = OMPSettings(ompdal.getPressSettings(press.press_id))
Expand All @@ -126,7 +188,10 @@ def index():
'omp.ignore_submissions') else -1

submissions = []
for submission_row in ompdal.getSubmissionsByPress(press.press_id, ignored_submission_id):
submission_rows = ompdal.getSubmissionsByPress(press.press_id, ignored_submission_id)


for submission_row in submission_rows:
authors = [OMPItem(author, OMPSettings(ompdal.getAuthorSettings(author.author_id)))
for author in ompdal.getAuthorsBySubmission(submission_row.submission_id)]
editors = [OMPItem(editor, OMPSettings(ompdal.getAuthorSettings(editor.author_id)))
Expand All @@ -153,9 +218,14 @@ def index():

submissions.append(submission)

submissions = sorted(submissions, key=lambda s: min(
s.associated_items.get('publication_dates', [datetime(1, 1, 1)])), reverse=True)
#submissions = sorted(submissions,key=lambda s: s.associated_items.get('category',None), reverse=False)
session.filters =request.vars.get('filter_by').strip('[').strip(']') if request.vars.get('filter_by') else session.get('filters', '')
session.per_page = int(request.vars.get('per_page')) if request.vars.get('per_page') else int(session.get('per_page', 20))
session.sort_by = request.vars.get('sort_by') if request.vars.get('sort_by') else session.get('sort_by', 'newest_to_oldest')

current = int(request.vars.get('page_nr', 1)) - 1

b = Browser(submissions,current,locale, session.get('per_page'), session.get('sort_by'), session.get('filters'))
submissions = b.process_submissions(b.submissions)

return locals()

Expand Down
17 changes: 16 additions & 1 deletion languages/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'Adresszeile3': 'Adresszeile3',
'Advisory Board': 'Beirat',
'Ajax Recipes': 'Ajax Rezepte',
'All': 'Alle',
'Altersempfehlung': 'Altersempfehlung',
'and': 'und',
'Ansichtsexemplar': 'Ansichtsexemplar',
Expand All @@ -68,6 +69,8 @@
'Are you sure you want to delete this object?': 'Sind Sie sich sicher, dass Sie dieses Objekt löschen wollen?',
'Auflage': 'Auflage',
'Auslieferungstermin': 'Auslieferungstermin',
'author': 'Autor',
'authors': 'Autor',
'Autoren': 'Autoren',
'Autoren : Vorname Nachname )': 'Autoren : Vorname Nachname )',
'Available Databases and Tables': 'Verfügbare Datenbanken und Tabellen',
Expand Down Expand Up @@ -100,6 +103,8 @@
'Cannot be empty': 'Darf nicht leer sein',
'Capitals': 'Capitals',
'Categories': 'Sparten',
'category': 'sparte',
'Category': 'Sparte',
'Chapters': 'Kapitel',
'Check to delete': 'Auswählen um zu löschen',
'Choose citation style': 'Zitationsstil auswählen',
Expand Down Expand Up @@ -130,6 +135,8 @@
'Database': 'Datenbank',
'Database %s select': 'Datenbank %s ausgewählt',
'Database Administration (appadmin)': 'Datenbankadministration (appadmin)',
'date': 'datum',
'Date': 'Datum',
'Dateiname PDF (cover)': 'Dateiname PDF (cover)',
'Dateiname PDF (innerwork)': 'Dateiname PDF (innerwork)',
'db': 'db',
Expand Down Expand Up @@ -168,6 +175,8 @@
'Farbraum': 'Farbraum',
'Felix M. Michl\nDie limitierte Auflage': 'Felix M. Michl\nDie limitierte Auflage',
'Felix M. Michl Die limitierte Auflage': 'Felix M. Michl Die limitierte Auflage',
'Filter': 'Filter',
'Filter By': 'Filter By',
'First name': 'Vorname',
'Follow us on Twitter': 'Besuchen Sie uns auf Twitter',
'For Authors': 'Informationen für Autoren',
Expand Down Expand Up @@ -282,13 +291,15 @@
'New Record': 'Neuer Eintrag',
'new record inserted': 'neuer Eintrag hinzugefügt',
'New Titles': 'Neuerscheinung',
'newest_to_oldest': 'Erscheinungsdatum (↓) ',
'News': 'Aktuelles',
'next %s rows': 'nächste %s Reihen',
'No databases in this application': 'Keine Datenbank in dieser Anwendung',
'Numerik 0': 'Numerik 0',
'Nur wenn check-trim-box yes ist, Standardwert 4 mm, kann aber frei gewählt werden.': 'Nur wenn check-trim-box yes ist, Standardwert 4 mm, kann aber frei gewählt werden.',
'Nur wenn Prüfung Trimbox "yes" ist, Standardwert 2,5 mm, kann aber frei gewählt werden. Bei Dezimalzahlen Trennzeichen "Punkt".': 'Nur wenn Prüfung Trimbox "yes" ist, Standardwert 2,5 mm, kann aber frei gewählt werden. Bei Dezimalzahlen Trennzeichen "Punkt".',
'Object or table name': 'Objekt- oder Tabellenname',
'oldest_to_newest': 'Erscheinungsdatum (↑)',
'ONIX': 'ONIX',
'Onix': 'Onix',
'Onix Additionals': 'Onix Additionals',
Expand Down Expand Up @@ -363,13 +374,15 @@
'Reihe': 'Reihe',
'Remember me (for 30 days)': 'Eingeloggt bleiben (30 Tage lang)',
'Reset Password key': 'Passwortschlüssel zurücksetzen',
'Results per Page': 'Treffer pro Seite',
'Rights and Licences': 'Rechte und Lizenzen',
'Role': 'Rolle',
'Roles': 'Rollen',
'Rows in Table': 'Tabellenreihen',
'Rows selected': 'Reihen ausgewählt',
'Rückenart': 'Rückenart',
'Save model as...': 'Speichere Vorlage als...',
'search': 'search',
'Search': 'Suche',
'Semantic': 'Semantik',
'Send': 'Verschicken',
Expand All @@ -388,6 +401,7 @@
'Sign Up': 'Sign Up',
'Size of cache:': 'Cachegröße:',
'Soon': 'Demnächst',
'sort by': 'Sortieren nach',
'Speicherung': 'Speicherung',
'Sprache': 'Sprache',
'state': 'Status',
Expand Down Expand Up @@ -415,8 +429,9 @@
'This email already has an account': 'This email already has an account',
'Time in Cache (h:m:s)': 'Zeit im Cache (h:m:s)',
'Timestamp': 'Zeitstempel',
'Titel': 'Titel',
'Titel der Original Ausgabe': 'Titel der Original Ausgabe',
'Title': 'Titel',
'title': 'titel',
'Titles': 'Titel',
'To be published %(date)s. ## %B %Y': 'Erscheint im %(date)s.',
'To be published %(date)s. ## %x': 'Erscheint am %(date)s.',
Expand Down
2 changes: 2 additions & 0 deletions languages/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
'New %(entity)s': 'New %(entity)s',
'New Record': 'New Record',
'New Search': 'New Search',
'newest_to_oldest': 'Newest to oldest',
'No records found': 'No records found',
'not authorized': 'not authorized',
'not in': 'not in',
Expand All @@ -172,6 +173,7 @@
'Other Plugins': 'Other Plugins',
'Other Recipes': 'Other Recipes',
'Overview': 'Overview',
'oldest_to_newest': 'oldest to newest',
'Password': 'Password',
"Password fields don't match": "Password fields don't match",
'please input your password again': 'please input your password again',
Expand Down
69 changes: 69 additions & 0 deletions models/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import logging, logging.handlers

class GAEHandler(logging.Handler):
"""
Logging handler for GAE DataStore
"""
def emit(self, record):

from google.appengine.ext import db

class Log(db.Model):
name = db.StringProperty()
level = db.StringProperty()
module = db.StringProperty()
func_name = db.StringProperty()
line_no = db.IntegerProperty()
thread = db.IntegerProperty()
thread_name = db.StringProperty()
process = db.IntegerProperty()
message = db.StringProperty(multiline=True)
args = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)

log = Log()
log.name = record.name
log.level = record.levelname
log.module = record.module
log.func_name = record.funcName
log.line_no = record.lineno
log.thread = record.thread
log.thread_name = record.threadName
log.process = record.process
log.message = record.msg
log.args = str(record.args)
log.put()

def get_configured_logger(name):
logger = logging.getLogger(name)
if (len(logger.handlers) == 0):
# This logger has no handlers, so we can assume it hasn't yet been configured
# (Configure logger)

# Create default handler
if request.env.web2py_runtime_gae:
# Create GAEHandler
handler = GAEHandler()
else:
# Create RotatingFileHandler
import os
formatter="%(asctime)s %(levelname)s %(process)s %(thread)s %(funcName)s():%(lineno)d %(message)s"
handler = logging.handlers.RotatingFileHandler(os.path.join(request.folder,'private/app.log'),maxBytes=1024,backupCount=2)
handler.setFormatter(logging.Formatter(formatter))

handler.setLevel(logging.DEBUG)

logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

# Test entry:
logger.debug(name + ' logger created')
else:
# Test entry:
logger.debug(name + ' already exists')

return logger

# Assign application logger to a global var

logger = get_configured_logger(request.application)
26 changes: 13 additions & 13 deletions models/z_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ def category_setting(c, name):


publishing_dict = [['for_authors', T('Information for Authors')],
['rights_and_licences', T('Rights and Licences')]
['peer_review', T('Peer Review')],
['rights_and_licences', T('Rights and Licences')],
['plagiarism', T('Plagiarism')],
['data_privacy', T('Data Privacy')]
]

publishing_dict_list = [LI(A(i[1], _href=URL('publishing', i[0])))
for i in publishing_dict]


quality_control_dict = [
['peer_review', T('Peer Review')],
['plagiarism', T('Plagiarism')],
['data_privacy', T('Data Privacy')],
]

quality_control_dict_list = [
LI(A(i[1], _href=URL('quality_control', i[0]))) for i in quality_control_dict]
def display_form():
form=FORM( INPUT(_name='search',_class="form-control", _placeholder=T("Search")),
#INPUT(_type='submit',_class="btn btn-default",),
_class="navbar-form navbar-left")
if form.accepts(request,session):
redirect(URL('catalog','search?q='+request.vars.search))
return form


response.menu = UL([LI(A(T('Home'),
Expand All @@ -88,10 +90,8 @@ def category_setting(c, name):
UL(publishing_dict_list,
_class="dropdown-menu"),
_class="dropdown"),
LI(XML(title('Quality Control')),
UL(quality_control_dict_list,
_class="dropdown-menu"),
_class="dropdown"),
#LI(display_form(), _class="dropdown")

],
_class="nav navbar-nav")

Expand Down
2 changes: 1 addition & 1 deletion modules
Submodule modules updated 2 files
+28 −22 ompbrowse.py
+4 −2 ompsolr.py
2 changes: 1 addition & 1 deletion static/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 74c1e04

Please sign in to comment.