Commit 1f046382 authored by Victor Mocelin's avatar Victor Mocelin

Alterado nomes no banco para ficar tudo em inglês

Adicionado verificação de unique para as tabelas events e people.
parent 71e7d2e1
Pipeline #1212 skipped
......@@ -20,9 +20,9 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services',
}
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS pessoas(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, nome TEXT NOT NULL, grr TEXT NOT NULL, email TEXT NOT NULL)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS palestras(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, nome TEXT NOT NULL, descricao TEXT NOT NULL, data TEXT NOT NULL, local TEXT NOT NULL, horas TEXT NOT NULL)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS presencas(palestra_id, pessoas_id, FOREIGN KEY(palestra_id) REFERENCES palestras(id), FOREIGN KEY(pessoas_id) REFERENCES pessoas(id))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, grr TEXT NOT NULL, email TEXT NOT NULL, UNIQUE (name, grr, email))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS events(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, desc TEXT NOT NULL, date TEXT NOT NULL, place TEXT NOT NULL, hours TEXT NOT NULL, UNIQUE (name, desc, date, place, hours))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people_events(event_id, person_id, FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES people(id))");
});
})
angular.module('app.controllers', [])
.controller('ceitificatorCtrl', function($scope, $ionicPlatform, EventsService) {
$ionicPlatform.ready(function(){
$scope.events = EventsService.getEvents();
console.log($scope.events);
$ionicPlatform.ready(function (){
$scope.events = EventsService.getEvents();
console.log($scope.events);
});
})
......@@ -12,26 +12,26 @@ angular.module('app.controllers', [])
$scope.addNewEvent = function (){
if ((!$scope.formData.eventName || $scope.formData.eventName.length === 0 || !$scope.formData.eventName.trim()) ||
(!$scope.formData.eventDesc || $scope.formData.eventDesc.length === 0 || !$scope.formData.eventDesc.trim()) ||
(!$scope.formData.eventDate || $scope.formData.eventDate.length === 0 || !$scope.formData.eventDate.trim()) ||
(!$scope.formData.eventPlace || $scope.formData.eventPlace.length === 0 || !$scope.formData.eventPlace.trim()) ||
(!$scope.formData.eventHours || $scope.formData.eventHours.length === 0 || !$scope.formData.eventHours.trim()))
(!$scope.formData.eventDate || $scope.formData.eventDate.length === 0 || !$scope.formData.eventDate.trim()) ||
(!$scope.formData.eventPlace || $scope.formData.eventPlace.length === 0 || !$scope.formData.eventPlace.trim()) ||
(!$scope.formData.eventHours || $scope.formData.eventHours.length === 0 || !$scope.formData.eventHours.trim()))
alert("WTF?");
else
EventsService.addNewEvent({eventName: $scope.formData.eventName, eventDesc: $scope.formData.eventDesc, eventDate: $scope.formData.eventDate, eventPlace: $scope.formData.eventPlace, eventHours: $scope.formData.eventHours});
};
$scope.showCertText = function (){
alert("Certificamos que !NOME! participou " + $scope.formData.eventDesc + " " + $scope.formData.eventName + " na ``I Semana Acadêmica de Informática'', realizada " + $scope.formData.eventDate + " na Universidade Federal do Paraná, " + $scope.formData.eventPlace + ", em Curitiba – PR, com a carga horária total de " + $scope.formData.eventHours + ".");
}
$scope.showCertText = function (){
alert("Certificamos que !NOME! participou " + $scope.formData.eventDesc + " " + $scope.formData.eventName + ", realizada " + $scope.formData.eventDate + " na Universidade Federal do Paraná, " + $scope.formData.eventPlace + ", em Curitiba – PR, com a carga horária total de " + $scope.formData.eventHours + ".");
}
})
.controller('listaDePresenAEventoXCtrl', function($scope, PeopleService) {
$scope.people = PeopleService.getPeople();
$scope.people = PeopleService.getPeople();
$scope.scan = function(){
cordova.plugins.barcodeScanner.scan(
function (result) {
console.log(result.text.split(','));
PeopleService.addNewPerson({name: result.text.split(',')[0].trim(), grr: result.text.split(',')[1].trim(), email: result.text.split(',')[2].trim()});
$scope.people = PeopleService.getPeople();
},
function (error) {
alert("Scanning failed: " + error);
......
......@@ -13,7 +13,7 @@ angular.module('app.services', [])
getEvents: function() {
events = [];
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
$cordovaSQLite.execute(db, "SELECT * FROM palestras")
$cordovaSQLite.execute(db, "SELECT * FROM events")
.then(function(res){
for(var i = 0; i < res.rows.length; i++){
events.push(res.rows.item(i));
......@@ -26,7 +26,7 @@ angular.module('app.services', [])
},
addNewEvent: function(event){
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
var query = "INSERT INTO palestras (nome, descricao, data, local, horas) VALUES (?,?,?,?,?)";
var query = "INSERT INTO events (name, desc, date, place, hours) VALUES (?,?,?,?,?)";
$cordovaSQLite.execute(db, query, [event.eventName, event.eventDesc, event.eventDate, event.eventPlace, event.eventHours])
.then(function(res){
console.log("res: " + res);
......@@ -42,7 +42,7 @@ angular.module('app.services', [])
getPeople: function() {
people = [];
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
$cordovaSQLite.execute(db, "SELECT * FROM pessoas")
$cordovaSQLite.execute(db, "SELECT * FROM people")
.then(function(res){
for(var i = 0; i < res.rows.length; i++){
people.push(res.rows.item(i));
......@@ -55,7 +55,7 @@ angular.module('app.services', [])
},
addNewPerson: function(person){
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
var query = "INSERT INTO pessoas (nome, grr, email) VALUES (?,?,?)";
var query = "INSERT INTO people (name, grr, email) VALUES (?,?,?)";
$cordovaSQLite.execute(db, query, [person.name, person.grr, person.email])
.then(function(res){
console.log("res: " + res);
......
......@@ -5,7 +5,7 @@
<div class="item item-body">
<a ui-sref="novoEvento" id="ceitificator-button2" class="button button-positive button-block icon-right ion-android-add-circle">Criar Novo</a>
<ion-list>
<ion-item ui-sref="listaDePresenAEventoX" ng-repeat="event in events">{{event.id}}: {{event.nome}} - {{event.data}} - {{event.horas}}</ion-item>
<ion-item ui-sref="listaDePresenAEventoX" ng-repeat="event in events">{{event.id}}: {{event.name}} - {{event.date}} - {{event.hours}}</ion-item>
</ion-list>
</div>
</div>
......
......@@ -4,7 +4,7 @@
<div class="item item-body">
<button id="listaDePresenAEventoX-button9" class="button button-positive button-block icon-right ion-qr-scanner" ng-click="scan()">Adicionar</button>
<ion-list>
<ion-item ng-repeat="person in people">{{person.nome}} - {{person.grr}} - {{person.email}}</ion-item>
<ion-item ng-repeat="person in people">{{person.name}} - {{person.grr}} - {{person.email}}</ion-item>
</ion-list>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment