rename registered to persons
This commit is contained in:
parent
227551f4b0
commit
ab837c3829
2 changed files with 38 additions and 22 deletions
|
@ -48,19 +48,34 @@
|
|||
|
||||
<div class="panel panel-primary table-striped top5">
|
||||
<div class="panel-heading">Events</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Person</th>
|
||||
<th>Attended</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="person in event.registered | orderBy:'surname'">
|
||||
<td><a href="/#/persons/{{person.person_id}}">{{person.name}} {{person.surname}}</a></td>
|
||||
<td><span class="glyphicon {{(event.person_data && event.person_data.attended) && 'glyphicon-ok-sign' || 'glyphicon-remove-sign'}}"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-body">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="query-persons">Search:</label>
|
||||
<input type="text" id="query-persons" class="form-control" placeholder="Name or email" ng-model="query">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="persons-order">Sort by:</label>
|
||||
<select id="persons-order" class="form-control" ng-model="orderProp">
|
||||
<option value="name" ng-selected="selected">Alphabetical</option>
|
||||
<option value="_id">ID</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Person</th>
|
||||
<th>Attended</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="person in event.persons | filter:query | orderBy:orderProp">
|
||||
<td><a href="/#/persons/{{person.person_id}}">{{person.name}} {{person.surname}}</a></td>
|
||||
<td><span class="glyphicon {{(event.person_data && event.person_data.attended) && 'glyphicon-ok-sign' || 'glyphicon-remove-sign'}}"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -59,7 +59,7 @@ class CollectionHandler(BaseHandler):
|
|||
@gen.coroutine
|
||||
def get(self, id_=None, resource=None, **kwargs):
|
||||
if resource:
|
||||
method = getattr(self, 'handle_%s' % resource, None)
|
||||
method = getattr(self, 'handle_get_%s' % resource, None)
|
||||
if method and callable(method):
|
||||
try:
|
||||
self.write(method(id_, **kwargs))
|
||||
|
@ -98,13 +98,13 @@ class PersonsHandler(CollectionHandler):
|
|||
collection = 'persons'
|
||||
object_id = 'person_id'
|
||||
|
||||
def handle_events(self, id_, **kwargs):
|
||||
events = self.db.query('events', {'registered.person_id': self.db.toID(id_)})
|
||||
def handle_get_events(self, id_, **kwargs):
|
||||
events = self.db.query('events', {'persons.person_id': self.db.toID(id_)})
|
||||
for event in events:
|
||||
person_data = {}
|
||||
for registered in event.get('registered') or []:
|
||||
if str(registered.get('person_id')) == id_:
|
||||
person_data = registered
|
||||
for persons in event.get('persons') or []:
|
||||
if str(persons.get('person_id')) == id_:
|
||||
person_data = persons
|
||||
break
|
||||
event['person_data'] = person_data
|
||||
return {'events': events}
|
||||
|
@ -128,6 +128,7 @@ class EbCSVImportPersonsHandler(BaseHandler):
|
|||
'Cognome': 'surname',
|
||||
'Nome': 'name',
|
||||
'E-mail': 'email',
|
||||
'Indirizzo e-mail': 'email',
|
||||
'Tipologia biglietto': 'ticket_kind',
|
||||
'Data partecipazione': 'attending_datetime',
|
||||
'Data check-in': 'checkin_datetime',
|
||||
|
@ -168,9 +169,9 @@ class EbCSVImportPersonsHandler(BaseHandler):
|
|||
'from_file': filename}
|
||||
person.update(registered_data)
|
||||
if not self.db.query('events',
|
||||
{'_id': event_id, 'registered.person_id': person_id}):
|
||||
{'_id': event_id, 'persons.person_id': person_id}):
|
||||
self.db.update('events', {'_id': event_id},
|
||||
{'registered': person},
|
||||
{'persons': person},
|
||||
operator='$addToSet')
|
||||
reply['new_in_event'] += 1
|
||||
self.write(reply)
|
||||
|
|
Loading…
Reference in a new issue