Andrea Fazzi пре 5 година
родитељ
комит
ac636f3966
3 измењених фајлова са 23 додато и 4 уклоњено
  1. 7 0
      documents/generators/list/list.go
  2. 3 2
      orm/document.go
  3. 13 2
      templates/documents_show.html.tpl

+ 7 - 0
documents/generators/list/list.go

@@ -162,6 +162,13 @@ func (generator *ListGenerator) Run(jobId uint) {
 
 	generate(teachers, funcMap)
 
+	job.End = time.Now()
+
+	err = client.UpdateJob(job)
+	if err != nil {
+		panic(err)
+	}
+
 	log.Println("Uploading files to the cloud...")
 	src, err := ioutil.ReadFile(filepath.Join("output", "elenco_docenti.pdf"))
 	if err != nil {

+ 3 - 2
orm/document.go

@@ -3,6 +3,7 @@ package orm
 import (
 	"log"
 	"net/http"
+	"time"
 
 	"github.com/jinzhu/gorm"
 
@@ -46,7 +47,7 @@ func GetDocumentAll(args map[string]string) (interface{}, error) {
 
 	id := args["id"]
 
-	if err := DB().Where("id = ?", id).Find(&document).Error; err != nil {
+	if err := DB().Preload("Jobs", "end <> ?", time.Time{}).Where("id = ?", id).Find(&document).Error; err != nil {
 		return nil, err
 	}
 
@@ -150,7 +151,7 @@ func GetDocumentForAdd(args map[string]string) (interface{}, error) {
 
 func GetDocumentExecute(args map[string]string) (interface{}, error) {
 	var document Document
-	if err := DB().Preload("Jobs").First(&document, args["id"]).Error; err != nil {
+	if err := DB().Preload("Jobs", "end <> ?", time.Time{}).First(&document, args["id"]).Error; err != nil {
 		return nil, err
 	}
 

+ 13 - 2
templates/documents_show.html.tpl

@@ -47,8 +47,19 @@
   <div class="row">
     <div class="col-md-12">
       
-      <h2 class="karmen-relation-header">Documenti prodotti</h2>
-      <p>Non è stato prodotto nessun documento.</p>
+      <h2 class="karmen-relation-header">Lavori in esecuzione</h2>
+      {{if .Data.Jobs}}
+      <div class="list-group" id="jobs_list_group">
+    	{{range $job := .Data.Jobs}}
+    	<a href="/jobs/{{$job.ID}}?{{query "tpl_layout" "base" "tpl_content" "jobs_show"}}" class="list-group-item list-group-item-action">
+    	  <span class="fa fa-file-alt"></span>
+    	  Il lavoro con ID {{$job.ID}} è in esecuzione.
+    	  {{end}}
+    	</a>
+      </div>
+      {{else}}
+      <p>Nessun lavoro è attualmente in esecuzione.</p>
+      {{end}}
     </div>
     
   </div>