Commit 678b6b011d1d357c8b34b355cdd3a83611bf97e5

Authored by Miguel Barao
1 parent 2ed48b70
Exists in master and in 1 other branch dev

- minor corrections.

MANUAL.md
... ... @@ -57,6 +57,20 @@ A test is just a yaml file with the configuration for that test. Look at `demo/t
57 57 Questions are defined in yaml files. Each yaml file contains a list of questions
58 58  
59 59  
  60 +
  61 +
  62 +
  63 +
  64 +
  65 +
  66 +
  67 +
  68 +
  69 +
  70 +
  71 +
  72 +
  73 +
60 74 Before using the program you need to
61 75  
62 76 1. Edit `config/server.conf` in the server directory and define
... ...
app.py
... ... @@ -35,7 +35,6 @@ class App(object):
35 35  
36 36 # database
37 37 engine = create_engine('sqlite:///{}'.format(self.testfactory['database']), echo=False)
38   - Base.metadata.create_all(engine) # Criate schema if needed FIXME no student '0'
39 38 self.Session = scoped_session(sessionmaker(bind=engine))
40 39  
41 40 try:
... ...
initdb.py
... ... @@ -44,11 +44,13 @@ try:
44 44 try:
45 45 csvreader = csv.DictReader(open(args.csvfile, encoding='iso-8859-1'), delimiter=';', quotechar='"')
46 46 except EnvironmentError:
47   - print('CSV file "{0}" not found!'.format(args.csvfile))
  47 + print('Error: CSV file "{0}" not found.'.format(args.csvfile))
  48 + session.rollback()
  49 + sys.exit(1)
48 50 else:
49 51 session.add_all([Student(id=r['N.º'], name=fix(r['Nome']), password='') for r in csvreader])
50 52 else:
51   - # otherwise add 5 fake students
  53 + # otherwise add a few fake students
52 54 fakes = [
53 55 ['1888', 'Fernando Pessoa'],
54 56 ['1799', 'Almeida Garrett'],
... ... @@ -65,8 +67,8 @@ try:
65 67 session.commit()
66 68  
67 69 except Exception:
68   - session.rollback()
69 70 print('Error: Database already exists.')
  71 + session.rollback()
70 72 sys.exit(1)
71 73  
72 74 else:
... ...
serve.py
... ... @@ -20,6 +20,7 @@ from tools import load_yaml
20 20  
21 21 # ============================================================================
22 22 # Authentication
  23 +# http://tools.cherrypy.org/wiki/AuthenticationAndAccessRestrictions
23 24 # ============================================================================
24 25 def check_auth(*args, **kwargs):
25 26 """A tool that looks in config for 'auth.require'. If found and it
... ... @@ -91,7 +92,6 @@ class AdminWebService(object):
91 92  
92 93 @cherrypy.tools.accept(media='application/json') # FIXME
93 94 def POST(self, **args):
94   - # print('POST', args) # FIXME
95 95 if args['cmd'] == 'allow':
96 96 if args['value'] == 'true':
97 97 return self.app.allow_student(args['name'])
... ... @@ -105,7 +105,7 @@ class AdminWebService(object):
105 105 return self.app.insert_new_student(uid=args['number'], name=args['name'])
106 106  
107 107 else:
108   - print(args)
  108 + print(args) # FIXME
109 109  
110 110 # ============================================================================
111 111 # Student webservice
... ... @@ -134,10 +134,10 @@ class Root(object):
134 134 self.app = app
135 135 t = TemplateLookup(directories=[TEMPLATES_DIR], input_encoding='utf-8')
136 136 self.template = {
137   - 'login': t.get_template('/login.html'),
138   - 'test': t.get_template('/test.html'),
139   - 'grade': t.get_template('/grade.html'),
140   - 'admin': t.get_template('/admin.html'),
  137 + 'login': t.get_template('/login.html'),
  138 + 'test': t.get_template('/test.html'),
  139 + 'grade': t.get_template('/grade.html'),
  140 + 'admin': t.get_template('/admin.html'),
141 141 'review': t.get_template('/review.html'),
142 142 }
143 143  
... ... @@ -260,7 +260,8 @@ class Root(object):
260 260 # --- ADMIN --------------------------------------------------------------
261 261 @cherrypy.expose
262 262 @require(name_is('0'))
263   - def admin(self, **reset_pw):
  263 + # def admin(self, **reset_pw):
  264 + def admin(self):
264 265 return self.template['admin'].render()
265 266  
266 267 # --- REVIEW -------------------------------------------------------------
... ...
templates/grade.html
... ... @@ -4,12 +4,13 @@
4 4 <meta charset="UTF-8">
5 5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 6 <meta name="viewport" content="width=device-width, initial-scale=1">
7   - <title> Teste </title>
  7 + <title>Teste</title>
8 8 <link rel="icon" href="/static/favicon.ico">
9 9  
10 10 <!-- Bootstrap -->
11 11 <link rel="stylesheet" href="/static/css/bootstrap.min.css">
12 12 <link rel="stylesheet" href="/static/css/bootstrap-theme.min.css"> <!-- optional -->
  13 + <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css">
13 14 <link rel="stylesheet" href="/static/css/test.css">
14 15  
15 16 <script src="/static/js/jquery.min.js"></script>
... ... @@ -36,10 +37,9 @@
36 37 <ul class="nav navbar-nav navbar-right">
37 38 <li class="dropdown">
38 39 <a class="dropdown-toggle" data-toggle="dropdown" href="#">
39   - <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
  40 + <i class="fa fa-user" aria-hidden="true"></i>
40 41 <span id="name">${t['student']['name']}</span>
41 42 (<span id="number">${t['student']['number']}</span>)
42   - <!-- <span class="caret"></span> -->
43 43 </a>
44 44 </li>
45 45 </ul>
... ...