code cleanup

This commit is contained in:
Davide Alberani 2016-07-09 20:24:45 +02:00
parent 075d878ac1
commit ed553faac2
7 changed files with 30 additions and 40 deletions

View file

@ -27,7 +27,7 @@
<div class="input-group input-group-lg">
<span class="input-group-addon min100">{{'Title' | translate}}</span>
<input type="text" class="form-control" placeholder="{{'Title' | translate}}" ng-model="event.title" ng-required="1">
<input type="text" class="form-control" placeholder="{{'Title' | translate}}" ng-model="event.title" ng-required="true">
</div>
<div class="input-group input-group-lg top5">
<span class="input-group-addon min100">{{'Tagline' | translate}}</span>
@ -46,7 +46,7 @@
<div class="form-group">
<label for="begin-date" class="col-sm-3 control-label">{{'begin date:' | translate}}</label>
<div id="begin-date" class="input-group col-sm-9">
<input type="text" class="form-control" datepicker-popup="dd-MMMM-yyyy" ng-model="event['begin-date']" is-open="opened" ng-required="true" />
<input type="text" class="form-control" datepicker-popup="dd-MMMM-yyyy" ng-model="event['begin-date']" is-open="opened" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="fa fa-calendar"></i></button>
</span>
@ -62,7 +62,7 @@
<div class="form-group">
<label for="end-date" class="col-sm-3 control-label">{{'End date:' | translate}}</label>
<div id="end-date" class="input-group col-sm-9">
<input type="text" class="form-control" datepicker-popup="dd-MMMM-yyyy" ng-model="event['end-date']" is-open="opened" ng-required="true" />
<input type="text" class="form-control" datepicker-popup="dd-MMMM-yyyy" ng-model="event['end-date']" is-open="opened" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="fa fa-calendar"></i></button>
</span>

View file

@ -44,8 +44,8 @@
<a ui-sref="event.view({id: event._id})" ng-if="!hasPermission('event|update')">{{event.title}}</a>
</strong>
</span>
<p>{{'Begins:' | translate}} {{event['begin-date'] | date:'fullDate'}} {{event['begin-time'] | date:'HH:mm'}}<br/>
{{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}</p>
<p><span ng-if="event['begin-date']">{{'Begins:' | translate}} {{event['begin-date'] | date:'fullDate'}} {{event['begin-time'] | date:'HH:mm'}}<br/></span>
<span ng-if="event['end-date']">{{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}</span></p>
</td>
<td ng-if="hasPermission('event:tickets-all|read')" class="hcenter">
<p><span ng-init="attendeesNr = ((event.tickets || []) | attendeesFilter).length">{{attendeesNr}}</span> / {{((event.tickets || []) | registeredFilter).length}} ({{((attendeesNr / ((event.tickets || []) | registeredFilter).length * 100) || 0).toFixed()}}%)</p>
@ -54,7 +54,7 @@
<button ng-if="hasPermission('event:tickets-all|create')" ng-click="$state.go('event.ticket.new', {id: event._id})" class="btn btn-link fa fa-user-plus" type="button" title="{{'Join this event' | translate}}"></button>
<button ng-if="hasPermission('tickets|update')" ng-click="$state.go('event.tickets', {id: event._id})" class="btn btn-link fa fa-list" type="button" title="{{'Manage attendees' | translate}}"></button>
<button ng-if="hasPermission('event|update')" ng-click="$state.go('event.edit', {id: event._id})" type="button" class="btn btn-link fa fa-cog fa-lg" title="{{'Edit' | translate}}"></button>
<button ng-if="hasPermission('event|delete')" ng-click="remove(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
<button ng-if="hasPermission('event|delete')" ng-click="deleteEvent(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
</td>
</tr>
</tbody>

View file

@ -7,8 +7,8 @@ var eventManControllers = angular.module('eventManControllers', []);
/* A controller that can be used to navigate. */
eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$location', 'Setting', 'Info', '$state',
function ($scope, $rootScope, $location, Setting, Info, $state) {
eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$location', 'Setting', '$state',
function ($scope, $rootScope, $location, Setting, $state) {
$scope.logo = {};
$scope.getLocation = function() {
@ -91,7 +91,7 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
});
});
$scope.remove = function(_id) {
$scope.deleteEvent = function(_id) {
var modalInstance = $uibModal.open({
scope: $scope,
templateUrl: 'modal-confirm-action.html',
@ -101,10 +101,9 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
}
});
modalInstance.result.then(function() {
Event.remove({'id': _id}, function() {
Event.delete({'id': _id}, function() {
$scope.events = Event.all();
}
);
});
});
};

View file

@ -1,6 +1,5 @@
/* i18n for Event(man) */
'use strict';
eventManApp.config(['$translateProvider', function ($translateProvider) {
$translateProvider.useStaticFilesLoader({

View file

@ -77,17 +77,6 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
eventManServices.factory('EventTicket', ['$resource', '$rootScope',
function($resource, $rootScope) {
return $resource('events/:id/tickets', {event_id: '@event_id', ticket_id: '@_id'}, {
get: {
method: 'GET',
url: 'events/:id/tickets/:ticket_id',
interceptor : {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
data = angular.fromJson(data);
return data.ticket;
}
},
all: {
method: 'GET',
url: '/tickets',
@ -102,6 +91,16 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
}
},
get: {
method: 'GET',
url: 'events/:id/tickets/:ticket_id',
interceptor : {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
data = angular.fromJson(data);
return data.ticket;
}
},
add: {
method: 'POST',
interceptor : {responseError: $rootScope.errorHandler},
@ -143,7 +142,6 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
eventManServices.factory('Setting', ['$resource', '$rootScope',
function($resource, $rootScope) {
return $resource('settings/', {}, {
query: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},

View file

@ -2,8 +2,8 @@
Classes and functions used to manage events and attendees database.
Copyright 2015 Davide Alberani <da@erlug.linux.it>
RaspiBO <info@raspibo.org>
Copyright 2015-2016 Davide Alberani <da@erlug.linux.it>
RaspiBO <info@raspibo.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -43,13 +43,6 @@ def convert_obj(obj):
return ObjectId(obj)
except:
pass
try:
i_obj = int(obj)
if i_obj > 2**64 - 1:
return obj
return i_obj
except:
pass
return obj

View file

@ -980,10 +980,14 @@ def run():
if options.debug:
logger.setLevel(logging.DEBUG)
ssl_options = {}
if os.path.isfile(options.ssl_key) and os.path.isfile(options.ssl_cert):
ssl_options = dict(certfile=options.ssl_cert, keyfile=options.ssl_key)
# database backend connector
db_connector = backend.EventManDB(url=options.mongo_url, dbName=options.db_name)
init_params = dict(db=db_connector, data_dir=options.data_dir, listen_port=options.port,
authentication=options.authentication, logger=logger)
authentication=options.authentication, logger=logger, ssl_options=ssl_options)
# If not present, we store a user 'admin' with password 'eventman' into the database.
if not db_connector.query('users', {'username': 'admin'}):
@ -1025,9 +1029,6 @@ def run():
cookie_secret='__COOKIE_SECRET__',
login_url='/login',
debug=options.debug)
ssl_options = {}
if os.path.isfile(options.ssl_key) and os.path.isfile(options.ssl_cert):
ssl_options = dict(certfile=options.ssl_cert, keyfile=options.ssl_key)
http_server = tornado.httpserver.HTTPServer(application, ssl_options=ssl_options or None)
logger.info('Start serving on %s://%s:%d', 'https' if ssl_options else 'http',
options.address if options.address else '127.0.0.1',
@ -1038,7 +1039,7 @@ def run():
ws_application = tornado.web.Application([_ws_handler], debug=options.debug)
ws_http_server = tornado.httpserver.HTTPServer(ws_application)
ws_http_server.listen(options.port+1, address='127.0.0.1')
logger.debug('Starting WebSocket on ws://127.0.0.1:%d', options.port+1)
logger.debug('Starting WebSocket on %s://127.0.0.1:%d', 'wss' if ssl_options else 'ws', options.port+1)
tornado.ioloop.IOLoop.instance().start()