Kaynağa Gözat

Finish departments prototype

Andrea Fazzi 6 yıl önce
ebeveyn
işleme
4e114db1b8

+ 444 - 441
compose/karmen/sql/karmen.sql → compose/karmen/sql/karmen_test.sql

@@ -1,441 +1,444 @@
--- MySQL dump 10.16  Distrib 10.3.9-MariaDB, for debian-linux-gnu (x86_64)
---
--- Host: localhost    Database: karmen_test
--- ------------------------------------------------------
--- Server version	10.3.9-MariaDB-1:10.3.9+maria~bionic
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-
---
--- Table structure for table `activities`
---
-
-DROP TABLE IF EXISTS `activities`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `activities` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `class_id` int(10) unsigned DEFAULT NULL,
-  `teacher_id` int(10) unsigned DEFAULT NULL,
-  `subject_id` int(10) unsigned DEFAULT NULL,
-  `hours` int(11) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_activities_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `activities`
---
-
-LOCK TABLES `activities` WRITE;
-/*!40000 ALTER TABLE `activities` DISABLE KEYS */;
-INSERT INTO `activities` VALUES (1,'2018-08-24 17:17:22','2018-08-24 17:17:22',NULL,'1 A MATEMATICA 2h',1,1,1,2),(2,'2018-08-24 17:18:01','2018-08-24 17:18:01',NULL,'1 A INGLESE 2h',1,2,3,2),(3,'2018-08-24 17:18:26','2018-08-24 17:18:26',NULL,'1 A ITALIANO 5h',1,3,2,5),(4,'2018-08-24 17:23:58','2018-08-24 17:23:58',NULL,'1 A STORIA DELL\'ARTE 2h',1,5,4,2),(5,'2018-08-24 17:24:20','2018-08-24 17:24:20',NULL,'1 A TECNOLOGIA 2h',1,4,9,2),(6,'2018-08-24 17:24:41','2018-08-24 17:24:41',NULL,'1 A FRANCESE 2h',1,7,7,2),(7,'2018-08-24 17:25:13','2018-08-24 17:25:13',NULL,'1 A RELIGIONE 2h',1,9,6,2),(8,'2018-08-24 17:25:44','2018-08-24 17:25:44',NULL,'1 A STORIA 2h',1,6,8,2),(9,'2018-08-24 17:26:15','2018-08-24 17:26:15',NULL,'1 A SCIENZE 2h',1,8,5,2);
-/*!40000 ALTER TABLE `activities` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `administratives`
---
-
-DROP TABLE IF EXISTS `administratives`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `administratives` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  `role` int(11) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_administratives_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `administratives`
---
-
-LOCK TABLES `administratives` WRITE;
-/*!40000 ALTER TABLE `administratives` DISABLE KEYS */;
-/*!40000 ALTER TABLE `administratives` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `classes`
---
-
-DROP TABLE IF EXISTS `classes`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `classes` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `coordinator_id` int(10) unsigned DEFAULT NULL,
-  `minuter_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_classes_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `classes`
---
-
-LOCK TABLES `classes` WRITE;
-/*!40000 ALTER TABLE `classes` DISABLE KEYS */;
-INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-08-24 17:26:35',NULL,'1 A',3,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
-/*!40000 ALTER TABLE `classes` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `department_teachers`
---
-
-DROP TABLE IF EXISTS `department_teachers`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `department_teachers` (
-  `department_id` int(10) unsigned NOT NULL,
-  `teacher_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`department_id`,`teacher_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `department_teachers`
---
-
-LOCK TABLES `department_teachers` WRITE;
-/*!40000 ALTER TABLE `department_teachers` DISABLE KEYS */;
-/*!40000 ALTER TABLE `department_teachers` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `departments`
---
-
-DROP TABLE IF EXISTS `departments`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `departments` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_departments_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `departments`
---
-
-LOCK TABLES `departments` WRITE;
-/*!40000 ALTER TABLE `departments` DISABLE KEYS */;
-/*!40000 ALTER TABLE `departments` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `directors`
---
-
-DROP TABLE IF EXISTS `directors`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `directors` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_directors_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `directors`
---
-
-LOCK TABLES `directors` WRITE;
-/*!40000 ALTER TABLE `directors` DISABLE KEYS */;
-/*!40000 ALTER TABLE `directors` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `issues`
---
-
-DROP TABLE IF EXISTS `issues`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `issues` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `description` varchar(255) DEFAULT NULL,
-  `type` int(10) unsigned DEFAULT NULL,
-  `reported` tinyint(1) DEFAULT NULL,
-  `teacher_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_issues_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `issues`
---
-
-LOCK TABLES `issues` WRITE;
-/*!40000 ALTER TABLE `issues` DISABLE KEYS */;
-/*!40000 ALTER TABLE `issues` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `schools`
---
-
-DROP TABLE IF EXISTS `schools`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `schools` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `address` varchar(255) DEFAULT NULL,
-  `domain` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_schools_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `schools`
---
-
-LOCK TABLES `schools` WRITE;
-/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
-INSERT INTO `schools` VALUES (1,'2018-08-24 17:19:56','2018-08-24 17:19:56',NULL,'Scuola media inferiore \"Leonardo da Vinci\"','via Castroneria 4, Perlizzi (TN)','scuolamediadavinci.gov.it');
-/*!40000 ALTER TABLE `schools` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `students`
---
-
-DROP TABLE IF EXISTS `students`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `students` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_students_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `students`
---
-
-LOCK TABLES `students` WRITE;
-/*!40000 ALTER TABLE `students` DISABLE KEYS */;
-/*!40000 ALTER TABLE `students` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `subjects`
---
-
-DROP TABLE IF EXISTS `subjects`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `subjects` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `department_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_subjects_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `subjects`
---
-
-LOCK TABLES `subjects` WRITE;
-/*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
-INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-08-24 17:09:21',NULL,'MATEMATICA',0),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-08-24 17:09:44',NULL,'INGLESE',0),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-08-24 17:22:31',NULL,'FRANCESE',0),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
-/*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teacher_classes`
---
-
-DROP TABLE IF EXISTS `teacher_classes`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teacher_classes` (
-  `teacher_id` int(10) unsigned NOT NULL,
-  `class_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`teacher_id`,`class_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teacher_classes`
---
-
-LOCK TABLES `teacher_classes` WRITE;
-/*!40000 ALTER TABLE `teacher_classes` DISABLE KEYS */;
-INSERT INTO `teacher_classes` VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1);
-/*!40000 ALTER TABLE `teacher_classes` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teacher_subjects`
---
-
-DROP TABLE IF EXISTS `teacher_subjects`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teacher_subjects` (
-  `subject_id` int(10) unsigned NOT NULL,
-  `teacher_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`subject_id`,`teacher_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teacher_subjects`
---
-
-LOCK TABLES `teacher_subjects` WRITE;
-/*!40000 ALTER TABLE `teacher_subjects` DISABLE KEYS */;
-INSERT INTO `teacher_subjects` VALUES (1,1),(2,3),(3,2),(4,5),(5,8),(6,9),(7,7),(8,6),(9,4);
-/*!40000 ALTER TABLE `teacher_subjects` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teachers`
---
-
-DROP TABLE IF EXISTS `teachers`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teachers` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  `hours` int(11) DEFAULT NULL,
-  `curr_hours` int(11) DEFAULT NULL,
-  `the_boss_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_teachers_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teachers`
---
-
-LOCK TABLES `teachers` WRITE;
-/*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
-INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0);
-/*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `the_bosses`
---
-
-DROP TABLE IF EXISTS `the_bosses`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `the_bosses` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_the_bosses_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `the_bosses`
---
-
-LOCK TABLES `the_bosses` WRITE;
-/*!40000 ALTER TABLE `the_bosses` DISABLE KEYS */;
-/*!40000 ALTER TABLE `the_bosses` ENABLE KEYS */;
-UNLOCK TABLES;
-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-
-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-
--- Dump completed on 2018-08-27  8:41:48
+-- MySQL dump 10.16  Distrib 10.3.9-MariaDB, for debian-linux-gnu (x86_64)
+--
+-- Host: localhost    Database: karmen_dev
+-- ------------------------------------------------------
+-- Server version	10.3.9-MariaDB-1:10.3.9+maria~bionic
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `activities`
+--
+
+DROP TABLE IF EXISTS `activities`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `activities` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `class_id` int(10) unsigned DEFAULT NULL,
+  `teacher_id` int(10) unsigned DEFAULT NULL,
+  `subject_id` int(10) unsigned DEFAULT NULL,
+  `hours` int(11) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_activities_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `activities`
+--
+
+LOCK TABLES `activities` WRITE;
+/*!40000 ALTER TABLE `activities` DISABLE KEYS */;
+INSERT INTO `activities` VALUES (1,'2018-08-24 17:17:22','2018-08-24 17:17:22',NULL,'1 A MATEMATICA 2h',1,1,1,2),(2,'2018-08-24 17:18:01','2018-08-24 17:18:01',NULL,'1 A INGLESE 2h',1,2,3,2),(3,'2018-08-24 17:18:26','2018-08-24 17:18:26',NULL,'1 A ITALIANO 5h',1,3,2,5),(4,'2018-08-24 17:23:58','2018-08-24 17:23:58',NULL,'1 A STORIA DELL\'ARTE 2h',1,5,4,2),(5,'2018-08-24 17:24:20','2018-08-24 17:24:20',NULL,'1 A TECNOLOGIA 2h',1,4,9,2),(6,'2018-08-24 17:24:41','2018-08-24 17:24:41',NULL,'1 A FRANCESE 2h',1,7,7,2),(7,'2018-08-24 17:25:13','2018-08-24 17:25:13',NULL,'1 A RELIGIONE 2h',1,9,6,2),(8,'2018-08-24 17:25:44','2018-08-24 17:25:44',NULL,'1 A STORIA 2h',1,6,8,2),(9,'2018-08-24 17:26:15','2018-08-24 17:26:15',NULL,'1 A SCIENZE 2h',1,8,5,2);
+/*!40000 ALTER TABLE `activities` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `administratives`
+--
+
+DROP TABLE IF EXISTS `administratives`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `administratives` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `surname` varchar(255) DEFAULT NULL,
+  `username` varchar(255) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `telephone_number` varchar(255) DEFAULT NULL,
+  `role` int(11) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_administratives_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `administratives`
+--
+
+LOCK TABLES `administratives` WRITE;
+/*!40000 ALTER TABLE `administratives` DISABLE KEYS */;
+/*!40000 ALTER TABLE `administratives` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `classes`
+--
+
+DROP TABLE IF EXISTS `classes`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `classes` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `coordinator_id` int(10) unsigned DEFAULT NULL,
+  `minuter_id` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_classes_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `classes`
+--
+
+LOCK TABLES `classes` WRITE;
+/*!40000 ALTER TABLE `classes` DISABLE KEYS */;
+INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-08-24 17:26:35',NULL,'1 A',3,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
+/*!40000 ALTER TABLE `classes` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `department_teachers`
+--
+
+DROP TABLE IF EXISTS `department_teachers`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `department_teachers` (
+  `department_id` int(10) unsigned NOT NULL,
+  `teacher_id` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`department_id`,`teacher_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `department_teachers`
+--
+
+LOCK TABLES `department_teachers` WRITE;
+/*!40000 ALTER TABLE `department_teachers` DISABLE KEYS */;
+/*!40000 ALTER TABLE `department_teachers` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `departments`
+--
+
+DROP TABLE IF EXISTS `departments`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `departments` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_departments_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `departments`
+--
+
+LOCK TABLES `departments` WRITE;
+/*!40000 ALTER TABLE `departments` DISABLE KEYS */;
+INSERT INTO `departments` VALUES (1,'2018-09-13 16:21:31','2018-09-13 16:30:10',NULL,'LINGUE STRANIERE');
+/*!40000 ALTER TABLE `departments` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `directors`
+--
+
+DROP TABLE IF EXISTS `directors`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `directors` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `surname` varchar(255) DEFAULT NULL,
+  `username` varchar(255) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `telephone_number` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_directors_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `directors`
+--
+
+LOCK TABLES `directors` WRITE;
+/*!40000 ALTER TABLE `directors` DISABLE KEYS */;
+/*!40000 ALTER TABLE `directors` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `issues`
+--
+
+DROP TABLE IF EXISTS `issues`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `issues` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `type` int(10) unsigned DEFAULT NULL,
+  `reported` tinyint(1) DEFAULT NULL,
+  `teacher_id` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_issues_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `issues`
+--
+
+LOCK TABLES `issues` WRITE;
+/*!40000 ALTER TABLE `issues` DISABLE KEYS */;
+/*!40000 ALTER TABLE `issues` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `schools`
+--
+
+DROP TABLE IF EXISTS `schools`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `schools` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `address` varchar(255) DEFAULT NULL,
+  `domain` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_schools_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `schools`
+--
+
+LOCK TABLES `schools` WRITE;
+/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
+INSERT INTO `schools` VALUES (1,'2018-08-24 17:19:56','2018-08-24 17:19:56',NULL,'Scuola media inferiore \"Leonardo da Vinci\"','via Castroneria 4, Perlizzi (TN)','scuolamediadavinci.gov.it');
+/*!40000 ALTER TABLE `schools` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `students`
+--
+
+DROP TABLE IF EXISTS `students`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `students` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `surname` varchar(255) DEFAULT NULL,
+  `username` varchar(255) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `telephone_number` varchar(255) DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_students_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `students`
+--
+
+LOCK TABLES `students` WRITE;
+/*!40000 ALTER TABLE `students` DISABLE KEYS */;
+/*!40000 ALTER TABLE `students` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `subjects`
+--
+
+DROP TABLE IF EXISTS `subjects`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `subjects` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `department_id` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_subjects_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `subjects`
+--
+
+LOCK TABLES `subjects` WRITE;
+/*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
+INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-08-24 17:09:21',NULL,'MATEMATICA',0),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-08-24 17:09:44',NULL,'INGLESE',0),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-09-13 16:52:35',NULL,'FRANCESE',1),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
+/*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `teacher_classes`
+--
+
+DROP TABLE IF EXISTS `teacher_classes`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `teacher_classes` (
+  `teacher_id` int(10) unsigned NOT NULL,
+  `class_id` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`teacher_id`,`class_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `teacher_classes`
+--
+
+LOCK TABLES `teacher_classes` WRITE;
+/*!40000 ALTER TABLE `teacher_classes` DISABLE KEYS */;
+INSERT INTO `teacher_classes` VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1);
+/*!40000 ALTER TABLE `teacher_classes` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `teacher_subjects`
+--
+
+DROP TABLE IF EXISTS `teacher_subjects`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `teacher_subjects` (
+  `subject_id` int(10) unsigned NOT NULL,
+  `teacher_id` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`subject_id`,`teacher_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `teacher_subjects`
+--
+
+LOCK TABLES `teacher_subjects` WRITE;
+/*!40000 ALTER TABLE `teacher_subjects` DISABLE KEYS */;
+INSERT INTO `teacher_subjects` VALUES (1,1),(2,3),(3,2),(4,5),(5,8),(6,9),(7,7),(8,6),(9,4);
+/*!40000 ALTER TABLE `teacher_subjects` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `teachers`
+--
+
+DROP TABLE IF EXISTS `teachers`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `teachers` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `surname` varchar(255) DEFAULT NULL,
+  `username` varchar(255) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `telephone_number` varchar(255) DEFAULT NULL,
+  `hours` int(11) DEFAULT NULL,
+  `curr_hours` int(11) DEFAULT NULL,
+  `the_boss_id` int(10) unsigned DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_teachers_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `teachers`
+--
+
+LOCK TABLES `teachers` WRITE;
+/*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
+INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0,NULL),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0,NULL),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0,NULL),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0,NULL),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0,NULL),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0,NULL),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0,NULL),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0,NULL),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0,NULL);
+/*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `the_bosses`
+--
+
+DROP TABLE IF EXISTS `the_bosses`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `the_bosses` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `surname` varchar(255) DEFAULT NULL,
+  `username` varchar(255) DEFAULT NULL,
+  `password` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `telephone_number` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_the_bosses_deleted_at` (`deleted_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `the_bosses`
+--
+
+LOCK TABLES `the_bosses` WRITE;
+/*!40000 ALTER TABLE `the_bosses` DISABLE KEYS */;
+/*!40000 ALTER TABLE `the_bosses` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2018-09-13 16:55:47

+ 1 - 1
generator/templates/add_update.tpl

@@ -35,7 +35,7 @@
 
     <div class="form-group has-feedback">
       <label class="control-label" for="{{.Model}}_name">Nome</label>
-      <input type="text" name="Name" class="form-control" id="{{.Model}}_name" placeholder="Nome" {{"{{if .Options.Get \"update\"}}"}} value="{{"{{.Data."}}{{.Model | toUpper}}{{".Name}}"}}" {{"{{end}}"}} required>
+      <input type="text" name="Name" class="form-control" id="{{.Model}}_name" placeholder="Nome" {{"{{if .Options.Get \"update\"}}"}} value="{{"{{.Data.Name}}"}}" {{"{{end}}"}} required>
     </div>
         
     <div class="form-group">

+ 1 - 1
generator/templates/show.tpl

@@ -20,7 +20,7 @@
 	    Crea
 	  </a>
 
-	  <a href="/{{.Models}}/add/?{{"{{query \"tpl_layout\" \"base\" \"tpl_content\" "}}"{{.Models}}_add_update" "update" "true"}}"  class="btn btn-primary">
+	  <a href="/{{.Models}}/{{"{{.Data.ID}}"}}/update?{{"{{query \"tpl_layout\" \"base\" \"tpl_content\" "}}"{{.Models}}_add_update" "update" "true"}}"  class="btn btn-primary">
 	    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
 	    Modifica
 	  </a>

+ 9 - 5
handlers/compose/sql/karmen_test.sql

@@ -106,7 +106,7 @@ CREATE TABLE `classes` (
 
 LOCK TABLES `classes` WRITE;
 /*!40000 ALTER TABLE `classes` DISABLE KEYS */;
-INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-08-24 17:26:35',NULL,'1 A',3,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
+INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-09-14 08:32:37',NULL,'1 A',0,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
 /*!40000 ALTER TABLE `classes` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -146,9 +146,10 @@ CREATE TABLE `departments` (
   `updated_at` timestamp NULL DEFAULT NULL,
   `deleted_at` timestamp NULL DEFAULT NULL,
   `name` varchar(255) DEFAULT NULL,
+  `coordinator_id` int(10) unsigned DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_departments_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -157,6 +158,7 @@ CREATE TABLE `departments` (
 
 LOCK TABLES `departments` WRITE;
 /*!40000 ALTER TABLE `departments` DISABLE KEYS */;
+INSERT INTO `departments` VALUES (1,'2018-09-13 16:21:31','2018-09-13 16:30:10',NULL,'LINGUE STRANIERE',NULL),(4,'2018-09-14 07:17:59','2018-09-14 08:24:29',NULL,'MATEMATICA',1);
 /*!40000 ALTER TABLE `departments` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -270,6 +272,7 @@ CREATE TABLE `students` (
   `password` varchar(255) DEFAULT NULL,
   `email` varchar(255) DEFAULT NULL,
   `telephone_number` varchar(255) DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_students_deleted_at` (`deleted_at`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -309,7 +312,7 @@ CREATE TABLE `subjects` (
 
 LOCK TABLES `subjects` WRITE;
 /*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
-INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-08-24 17:09:21',NULL,'MATEMATICA',0),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-08-24 17:09:44',NULL,'INGLESE',0),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-08-24 17:22:31',NULL,'FRANCESE',0),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
+INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-09-14 07:31:50',NULL,'MATEMATICA',4),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-09-14 07:14:36',NULL,'INGLESE',1),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-09-13 16:52:35',NULL,'FRANCESE',1),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
 /*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -382,6 +385,7 @@ CREATE TABLE `teachers` (
   `hours` int(11) DEFAULT NULL,
   `curr_hours` int(11) DEFAULT NULL,
   `the_boss_id` int(10) unsigned DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_teachers_deleted_at` (`deleted_at`)
 ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
@@ -393,7 +397,7 @@ CREATE TABLE `teachers` (
 
 LOCK TABLES `teachers` WRITE;
 /*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
-INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0);
+INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0,NULL),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0,NULL),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0,NULL),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0,NULL),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0,NULL),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0,NULL),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0,NULL),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0,NULL),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0,NULL);
 /*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -438,4 +442,4 @@ UNLOCK TABLES;
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2018-08-24 18:49:02
+-- Dump completed on 2018-09-14  8:42:51

+ 3 - 1
handlers/handlers.go

@@ -181,8 +181,10 @@ func get(w http.ResponseWriter, r *http.Request, model string, pattern PathPatte
 }
 
 func respondWithError(w http.ResponseWriter, r *http.Request, err error) {
+	respFormat := renderer.GetContentFormat(r)
 	w.WriteHeader(http.StatusInternalServerError)
-	renderer.Render[r.URL.Query().Get("format")](w, r, err)
+	// renderer.Render[r.URL.Query().Get("format")](w, r, err)
+	renderer.Render[respFormat](w, r, err)
 }
 
 func post(w http.ResponseWriter, r *http.Request, model string, pattern PathPattern) {

+ 33 - 0
handlers/handlers_test.go

@@ -367,3 +367,36 @@ func getTeacherJSON(id uint) *orm.Teacher {
 	return teacher
 
 }
+
+func (t *testSuite) TestGetDepartmentJSON() {
+	var (
+		department *orm.Department
+		response   renderer.JsonResponse
+	)
+
+	req, err := http.NewRequest("GET", "/api/departments/1?format=json", nil)
+	if err != nil {
+		panic(err)
+	}
+
+	pattern := PathPattern{"/api/%s/{id}", "", []string{"GET"}}
+
+	rr := httptest.NewRecorder()
+
+	router := mux.NewRouter()
+	router.Handle("/api/departments/{id}", modelHandler("departments", pattern))
+	router.ServeHTTP(rr, req)
+
+	t.Equal(http.StatusOK, rr.Code)
+
+	if !t.Failed() {
+		err := json.Unmarshal(rr.Body.Bytes(), &response)
+		t.Nil(err)
+		if !t.Failed() {
+			err := json.Unmarshal(response.Result, &department)
+			t.Nil(err)
+			t.Equal("LINGUE STRANIERE", department.Name)
+		}
+	}
+
+}

+ 9 - 5
orm/compose/sql/karmen_test.sql

@@ -106,7 +106,7 @@ CREATE TABLE `classes` (
 
 LOCK TABLES `classes` WRITE;
 /*!40000 ALTER TABLE `classes` DISABLE KEYS */;
-INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-08-24 17:26:35',NULL,'1 A',3,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
+INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-09-14 08:32:37',NULL,'1 A',0,2),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2);
 /*!40000 ALTER TABLE `classes` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -146,9 +146,10 @@ CREATE TABLE `departments` (
   `updated_at` timestamp NULL DEFAULT NULL,
   `deleted_at` timestamp NULL DEFAULT NULL,
   `name` varchar(255) DEFAULT NULL,
+  `coordinator_id` int(10) unsigned DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_departments_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -157,6 +158,7 @@ CREATE TABLE `departments` (
 
 LOCK TABLES `departments` WRITE;
 /*!40000 ALTER TABLE `departments` DISABLE KEYS */;
+INSERT INTO `departments` VALUES (1,'2018-09-13 16:21:31','2018-09-13 16:30:10',NULL,'LINGUE STRANIERE',NULL),(4,'2018-09-14 07:17:59','2018-09-14 08:24:29',NULL,'MATEMATICA',1);
 /*!40000 ALTER TABLE `departments` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -270,6 +272,7 @@ CREATE TABLE `students` (
   `password` varchar(255) DEFAULT NULL,
   `email` varchar(255) DEFAULT NULL,
   `telephone_number` varchar(255) DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_students_deleted_at` (`deleted_at`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -309,7 +312,7 @@ CREATE TABLE `subjects` (
 
 LOCK TABLES `subjects` WRITE;
 /*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
-INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-08-24 17:09:21',NULL,'MATEMATICA',0),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-08-24 17:09:44',NULL,'INGLESE',0),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-08-24 17:22:31',NULL,'FRANCESE',0),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
+INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-09-14 07:31:50',NULL,'MATEMATICA',4),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-09-14 07:14:36',NULL,'INGLESE',1),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-09-13 16:52:35',NULL,'FRANCESE',1),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0);
 /*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -382,6 +385,7 @@ CREATE TABLE `teachers` (
   `hours` int(11) DEFAULT NULL,
   `curr_hours` int(11) DEFAULT NULL,
   `the_boss_id` int(10) unsigned DEFAULT NULL,
+  `plain_password` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `idx_teachers_deleted_at` (`deleted_at`)
 ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
@@ -393,7 +397,7 @@ CREATE TABLE `teachers` (
 
 LOCK TABLES `teachers` WRITE;
 /*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
-INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0);
+INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0,NULL),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0,NULL),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0,NULL),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0,NULL),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0,NULL),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0,NULL),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0,NULL),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0,NULL),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0,NULL);
 /*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -438,4 +442,4 @@ UNLOCK TABLES;
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2018-08-24 18:49:02
+-- Dump completed on 2018-09-14  8:35:52

+ 54 - 19
orm/department.go

@@ -9,21 +9,36 @@ import (
 
 type Department struct {
 	gorm.Model
-	Name     string
+	Name string
+
+	CoordinatorID uint `schema:"coordinator_id"`
+	Coordinator   Teacher
+
 	Subjects []*Subject
 	Teachers []*Teacher
 }
 
+type DepartmentForUpdate struct {
+	Department          Department
+	AllTeachers         []*Teacher
+	SelectedCoordinator map[uint]string
+	SelectedMinuter     map[uint]string
+}
+
+type DepartmentForAdd struct {
+	AllTeachers []*Teacher
+}
+
 var (
 	selectUniqueDepartmentTeachers = `
-SELECT DISTINCT classes.* FROM activities 
-INNER JOIN classes on classes.id=activities.class_id 
-WHERE teacher_id=?`
+SELECT DISTINCT teachers.* FROM subjects 
+INNER JOIN activities ON activities.subject_id=subjects.id 
+INNER JOIN teachers ON activities.teacher_id=teachers.id 
+WHERE department_id=?`
 
 	selectUniqueDepartmentSubjects = `
-SELECT DISTINCT subjects.* FROM activities 
-INNER JOIN subjects on subjects.id=activities.subject_id 
-WHERE activities.teacher_id=?`
+SELECT * FROM subjects
+WHERE department_id=?`
 )
 
 func (d *Department) GetID() uint { return d.ID }
@@ -53,6 +68,14 @@ func GetDepartmentAll(args map[string]string) (interface{}, error) {
 		return nil, err
 	}
 
+	if department.CoordinatorID != 0 {
+		if !DB().First(&department.Coordinator, department.CoordinatorID).RecordNotFound() {
+			if err := DB().First(&department.Coordinator, department.CoordinatorID).Error; err != nil {
+				return nil, err
+			}
+		}
+	}
+
 	return &department, nil
 }
 
@@ -137,22 +160,34 @@ func DeleteDepartment(args map[string]string, r *http.Request) (IDer, error) {
 	return department.(*Department), nil
 }
 
-// func GetDepartmentForUpdate(args map[string]string) (interface{}, error) {
-// 	id := args["id"]
+func GetDepartmentForAdd(args map[string]string) (interface{}, error) {
+	var data DepartmentForAdd
 
-// 	if err := DB().First(&data.Subject, id).Error; err != nil {
-// 		return nil, err
-// 	}
+	if err := DB().Find(&data.AllTeachers).Error; err != nil {
+		return nil, err
+	}
 
-// 	if err := DB().Find(&data.AllDepartments).Error; err != nil {
-// 		return nil, err
-// 	}
+	return data, nil
+}
 
-// 	data.SelectedDepartment = make(map[uint]string)
-// 	data.SelectedDepartment[data.Subject.DepartmentID] = "selected"
+func GetDepartmentForUpdate(args map[string]string) (interface{}, error) {
+	var data DepartmentForUpdate
 
-// 	return data, nil
-// }
+	id := args["id"]
+
+	if err := DB().Preload("Coordinator").First(&data.Department, id).Error; err != nil {
+		return nil, err
+	}
+
+	if err := DB().Find(&data.AllTeachers).Error; err != nil {
+		return nil, err
+	}
+
+	data.SelectedCoordinator = make(map[uint]string)
+	data.SelectedCoordinator[data.Department.CoordinatorID] = "selected"
+
+	return data, nil
+}
 
 func (t *Department) GetTeachers() ([]*Teacher, error) {
 	if err := DB().Raw(selectUniqueDepartmentTeachers, t.ID).Scan(&t.Teachers).Error; err != nil {

+ 2 - 2
orm/mappings.go

@@ -38,8 +38,8 @@ var (
 		// Departments
 		"/departments":             GetDepartmentsAll,
 		"/departments/{id}":        GetDepartmentAll,
-		"/departments/{id}/update": GetDepartment,
-		"/departments/add/":        GetNothing,
+		"/departments/{id}/update": GetDepartmentForUpdate,
+		"/departments/add/":        GetDepartmentForAdd,
 
 		"/api/departments":             GetDepartmentsAll,
 		"/api/departments/{id}":        GetDepartmentAll,

+ 34 - 4
orm/orm_test.go

@@ -199,16 +199,46 @@ func (t *testSuite) TestCreateDeleteTeacher() {
 func (t *testSuite) TestGetDepartments() {
 	departments, err := GetDepartments(map[string]string{})
 	t.Nil(err)
-	t.Equal(9, len(departments.([]*Department)))
+	t.Equal(2, len(departments.([]*Department)))
 
 	if !t.Failed() {
 		department := departments.([]*Department)[0]
 		subjects, err := department.GetSubjects()
 		t.Nil(err)
-		t.Equal(1, len(subjects))
-		t.Equal(1, len(department.Subjects))
+		t.Equal(2, len(subjects))
+		t.Equal(2, len(department.Subjects))
 
 		subject := subjects[0]
-		t.Equal("MATEMATICA", subject.Name)
+		t.Equal("INGLESE", subject.Name)
 	}
 }
+
+func (t *testSuite) TestGetDepartment() {
+	department, err := GetDepartment(map[string]string{"id": "1"})
+	t.Nil(err)
+	if !t.Failed() {
+		t.Equal("LINGUE STRANIERE", department.(*Department).Name)
+	}
+
+}
+
+func (t *testSuite) TestGetDepartmentAll() {
+	department, err := GetDepartmentAll(map[string]string{"id": "1"})
+	t.Nil(err)
+	if !t.Failed() {
+		t.Equal("INGLESE", department.(*Department).Subjects[0].Name)
+		t.Equal("FRANCESE", department.(*Department).Subjects[1].Name)
+		t.Equal("DONADONI", department.(*Department).Teachers[0].Surname)
+		t.Equal("DELLE ROSE", department.(*Department).Teachers[1].Surname)
+	}
+
+}
+
+func (t *testSuite) TestGetSubjectForAdd() {
+	data, err := GetSubjectForAdd(nil)
+	t.Nil(err)
+	if !t.Failed() {
+		t.Equal("LINGUE STRANIERE", data.(SubjectForAdd).AllDepartments[0].Name)
+	}
+
+}

+ 1 - 1
orm/subject.go

@@ -17,7 +17,7 @@ type Subject struct {
 	gorm.Model
 
 	Name         string
-	DepartmentID uint
+	DepartmentID uint `schema:"department_id"`
 
 	Teachers   []*Teacher
 	Activities []*Activity

+ 1 - 1
templates/classes.html.tpl

@@ -32,7 +32,7 @@
 	<span class="glyphicon glyphicon-blackboard"></span>
 	{{$class.Name}}
 	<div class="text-right">
-	  {{range $teacher := $class.Teachers}}
+ 	  {{range $teacher := $class.Teachers}}
 	  <small>{{$teacher.Surname}}</small>
 	  {{end}}
 	</div>

+ 17 - 3
templates/departments.html.tpl

@@ -5,12 +5,12 @@
   <div class="karmen-info-header">
     <div class="row">
       <div class="col-md-8">
-	<h1>departments</h1>
+	<h1>Dipartimenti</h1>
       </div>
       <div class="col-md-4">
 	<a href="/departments/add/?{{query "tpl_layout" "base" "tpl_content" "departments_add_update"}}" class="btn btn-primary pull-right">
 	  <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
-	  Crea nuovo department
+	  Crea nuovo dipartimento
 	</a>
       </div>
     </div>
@@ -29,9 +29,23 @@
     <a class="list-group-item clearfix" href="/departments/{{$department.ID}}?{{query "tpl_layout" "base" "tpl_content" "departments_show"}}">
       <span class="glyphicon glyphicon-briefcase"></span>
       {{$department.Name}}
+
       <div class="text-right">
-	<small>optional tag goes here</small>
+	
+	{{if $department.Subjects}}
+	{{range $subject := $department.Subjects}}
+	<small>{{$subject.Name}}</small>
+	{{end}}
+	{{end}}
+
+	{{if $department.Teachers}}
+	{{range $teacher := $department.Teachers}}
+	<small>{{$teacher.Surname}}</small>
+	{{end}}
+	{{end}}
+
       </div>
+
     </a>
     {{end}}
   </div>

+ 24 - 7
templates/departments_add_update.html.tpl

@@ -4,12 +4,12 @@
 
   {{if .Options.Get "update"}}
   <ol class="breadcrumb">
-    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">department</a></li>
+    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">Dipartimento</a></li>
     <li class="active"><a href="#">Aggiorna department</a></li>
   </ol>  
   {{else}}
   <ol class="breadcrumb">
-    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">department</a></li>
+    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">Dipartimento</a></li>
     <li class="active"><a href="#">Aggiungi</a></li>
   </ol>
   {{end}}
@@ -18,17 +18,17 @@
   <div class="karmen-info-header">
     <div class="row">
       <div class="col-md-8">
-	<h1>Aggiorna department</h1>
+	<h1>Aggiorna il dipartimento</h1>
       </div>
     </div>
   </div>
   
   {{else}}
-  <h1 class="karmen-info-header">Crea nuovo department</h1>
+  <h1 class="karmen-info-header">Crea nuovo dipartimento</h1>
   {{end}}
 
   {{if .Options.Get "update"}}
-  <form id="form_departments_add_update" action="/departments/{{.ID}}/update" method="POST" role="form" data-toggle="validator">
+  <form id="form_departments_add_update" action="/departments/{{.Data.Department.ID}}/update" method="POST" role="form" data-toggle="validator">
   {{else}}
   <form id="form_departments_add_update" action="/departments/add/" method="POST" role="form" data-toggle="validator">
   {{end}}
@@ -37,11 +37,28 @@
       <label class="control-label" for="department_name">Nome</label>
       <input type="text" name="Name" class="form-control" id="department_name" placeholder="Nome" {{if .Options.Get "update"}} value="{{.Data.Department.Name}}" {{end}} required>
     </div>
-        
+
+    <div class="form-group">
+      <label class="control-label" for="coordinator_id">Coordinatore</label>
+      <select name="coordinator_id" class="form-control selectpicker" id="coordinator_id" placeholder="Coordinatore" data-live-search="true" form="form_departments_add_update" title="Seleziona il nome del coordinatore" data-dropup-auto="false">
+	<option value="0"></option>
+  	{{range $teacher := .Data.AllTeachers}}
+	{{if $.Options.Get "update"}}
+  	<option
+	  value="{{$teacher.ID}}"
+	  {{index $.Data.SelectedCoordinator $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
+	</option>
+	{{else}}
+  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
+	{{end}}
+  	{{end}}
+      </select>
+    </div>
+
     <div class="form-group">
       <button type="submit" class="btn btn-primary">Salva</button>
       {{if .Options.Get "update"}}
-      <a href="/departments/{{.Data.ID}}?{{query "tpl_layout" "base" "tpl_content" "departments_show"}}" class="btn btn-default">Annulla</a>
+      <a href="/departments/{{.Data.Department.ID}}?{{query "tpl_layout" "base" "tpl_content" "departments_show"}}" class="btn btn-default">Annulla</a>
       {{else}}
       <a href="/departments/?{{query "tpl_layout" "base" "tpl_content" "departments"}}" class="btn btn-default">Annulla</a>
       {{end}}

+ 52 - 18
templates/departments_show.html.tpl

@@ -3,7 +3,7 @@
 <div class="container">
 
   <ol class="breadcrumb">
-    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">departments</a></li>
+    <li><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">Dipartimenti</a></li>
     <li class="active"><a href="#">{{.Data.Name}}</a></li>
   </ol>
 
@@ -20,7 +20,7 @@
 	    Crea
 	  </a>
 
-	  <a href="/departments/add/?{{query "tpl_layout" "base" "tpl_content" "departments_add_update" "update" "true"}}"  class="btn btn-primary">
+	  <a href="/departments/{{.Data.ID}}/update?{{query "tpl_layout" "base" "tpl_content" "departments_add_update" "update" "true"}}"  class="btn btn-primary">
 	    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
 	    Modifica
 	  </a>
@@ -37,25 +37,59 @@
   </div>
 
   <div class="row">
+
     <div class="col-md-12">
-      
-      <h2 class="karmen-relation-header">sub items</h2>
-      {{if .Data.Items}}
-      <div class="list-group" id="materie_list_group">
-    	<a href="/subjects/{{.Data.Subject.ID}}?{{query "tpl_layout" "base" "tpl_content" "subjects_show"}}" class="list-group-item clearfix">
-    	  <span class="glyphicon glyphicon-book"></span>
-    	  {{.Data.Subject.Name}}
-    	</a>
+      <h2 class="karmen-relation-header">Coordinatore del dipartimento</h2>
+      <div class="list-group" id="departments_list_group">
+	{{if ne .Data.Coordinator.ID 0}}
+	<a href="/teachers/{{.Data.Coordinator.ID}}?{{query "tpl_layout" "base" "tpl_content" "teachers_show"}}" class="list-group-item clearfix">
+	  <span class="glyphicon glyphicon-user"></span>
+	  {{.Data.Coordinator.Surname}} {{.Data.Coordinator.Name}}
+	  <div class="text-right">
+	    <small>Coordinatore</small>
+	  </div>
+	</a>
+	{{else}}
+	<span class="list-group-item clearfix">Nessun coordinatore</span>
+	{{end}}
       </div>
-      {{else}}
-      <p>All'attività non è associata alcuna materia
-    	didattica. Clicca <a href="/activities/update?{{query "tpl_layout" "base" "tpl_content" "activities_add_update"}}">qui</a> per
-    	modificare questa attività didattica.</p>
-      {{end}}
     </div>
     
-  </div>
+    <div class="col-md-12">
+      <h2 class="karmen-relation-header">Docenti del dipartimento</h2>
+      {{if not .Data.Teachers}}
+      <p>Nel dipartimento non è presente alcun docente
+	didattica. Clicca <a href="/activities/add/?{{query "tpl_layout" "base" "tpl_content" "activities_add_update"}}">qui</a> per creare
+	una nuova attività didattica.</p>
+      {{else}}
+      <div class="list-group" id="teachers_list_group">
+	{{range $teacher := .Data.Teachers}}
+	<a class="list-group-item clearfix" href="/teachers/{{$teacher.ID}}?{{query "tpl_layout" "base" "tpl_content" "teachers_show"}}">
+	  <span class="glyphicon glyphicon-user"></span>
+	  {{$teacher.Surname}} {{$teacher.Name}}
+	</a>
+	{{end}}
+      </div>
+      {{end}}
+    </div>    
 
-</div>    
+    <div class="col-md-12">
+      <h2 class="karmen-relation-header">Materie afferenti al dipartimento</h2>
+      {{if not .Data.Teachers}}
+      <p>Nel dipartimento non è presente alcuna materia
+	didattica. Clicca <a href="/activities/add/?{{query "tpl_layout" "base" "tpl_content" "activities_add_update"}}">qui</a> per creare
+	una nuova attività didattica.</p>
+      {{else}}
+      <div class="list-group" id="subjects_list_group">
+	{{range $subject := .Data.Subjects}}
+	<a class="list-group-item clearfix" href="/subjects/{{$subject.ID}}?{{query "tpl_layout" "base" "tpl_content" "subjects_show"}}">
+	  <span class="glyphicon glyphicon-user"></span>
+	  {{$subject.Name}}
+	</a>
+	{{end}}
+	
+      </div>
+      {{end}}
+    </div>    
 
-{{ end }}
+    {{ end }}

+ 18 - 1
templates/subjects_add_update.html.tpl

@@ -31,7 +31,24 @@
       <label class="control-label" for="subject_name">Nome</label>
       <input type="text" name="Name" class="form-control" id="subject_name" placeholder="Nome" {{if .Options.Get "update"}} value="{{.Data.Subject.Name}}" {{end}} required>
     </div>
-        
+    
+    <div class="form-group">
+      <label class="control-label" for="department_id">Dipartimento</label>
+      <select name="department_id" class="form-control selectpicker" id="department_id" placeholder="Dipartimento" data-live-search="true" form="form_subjects_add_update" title="Seleziona il nome del dipartimento" data-dropup-auto="false" required>
+	<option value="0"></option>
+  	{{range $department := .Data.AllDepartments}}
+	{{if $.Options.Get "update"}}
+  	<option
+	   value="{{$department.ID}}"
+	   {{index $.Data.SelectedDepartment $department.ID}}>{{$department.Name}}
+	</option>
+	{{else}}
+  	<option value="{{$department.ID}}">{{$department.Name}}</option>
+	{{end}}
+  	{{end}}
+      </select>
+    </div>
+	
     <div class="form-group">
       <button type="submit" class="btn btn-primary">Salva</button>
       {{if .Options.Get "update"}}