瀏覽代碼

app, html: handling job states

Nikola Kotur 10 年之前
父節點
當前提交
6bc7392535
共有 6 個文件被更改,包括 28 次插入19 次删除
  1. 2 2
      phosic/routes.py
  2. 5 0
      static/css/narrow.css
  3. 0 2
      templates/job-failed.html
  4. 9 0
      templates/job-info.html
  5. 9 8
      templates/job-pending.html
  6. 3 7
      templates/job-ready.html

+ 2 - 2
phosic/routes.py

@@ -63,11 +63,11 @@ def jobs(job_id):
     task = tasks.make_video.AsyncResult(job.task_uuid)
     if task.ready():
         if task.get():
-            if os.path.exists(jobdir + job_id + ".mkv"):
+            if os.path.exists(jobdir + job_id + ".mkv") and job.state != models.JOB_FAILED:
                 return render_template('job-ready.html', job=job)
         return render_template('job-failed.html', job=job)
 
-    return render_template('job-pending.html', job=job)
+    return render_template('job-pending.html', job=job, started=True if job.state == models.JOB_STARTED else False)
 
 @app.route('/about/')
 def about():

+ 5 - 0
static/css/narrow.css

@@ -85,3 +85,8 @@ body {
   color: #fff;
   background-color: #A6D6FF;
 }
+
+/* Debuging */
+.debug-info {
+  border:1px dashed red;
+}

+ 0 - 2
templates/job-failed.html

@@ -14,8 +14,6 @@
 
     <p>Please try again later. You can send us this <code>{{ job.task_uuid }}</code> to help us figure out what happened. If you chose to do so, please send it to us before {{ job.expires.strftime('%d %b %Y at %H:%M') }}, otherwise all about this video will be deleted by then.</p>
 
-    {{ job.exception }}
-
   </div>
 </div>
 

+ 9 - 0
templates/job-info.html

@@ -0,0 +1,9 @@
+<div class="debug-info">
+	<p>I am a job {{ job.id }}</p>
+	<p>My uuid is {{ job.task_uuid }}</p>
+	<p>I was created {{ job.created }}</p>
+	<p>I was finished {{ job.finished }}</p>
+	<p>I will expire {{ job.expires }}</p>
+	<p>My pic is: {{ job.pic_name }}</p>
+	<p>My mp3 is: {{ job.mp3_name }}</p>
+</div>

+ 9 - 8
templates/job-pending.html

@@ -4,14 +4,15 @@
 {% endblock %}
 
 {% block main %}
-job is pending
 
-<p>I am a job {{ job.id }}</p>
-<p>My uuid is {{ job.task_uuid }}</p>
-<p>I was created {{ job.created }}</p>
-<p>I was finished {{ job.finished }}</p>
-<p>I will expire {{ job.expires }}</p>
-<p>My pic is: {{ job.pic_name }}</p>
-<p>My mp3 is: {{ job.mp3_name }}</p>
+{% if started %}
+<p>We are currently making your video, come back shortly!</p>
+{% else %}
+<p>We got your files and we are about to start making your video!</p>
+{% endif %}
+
+{% if config["DEBUG"] %}
+{% include 'job-info.html' %}
+{% endif %}
 
 {% endblock %}

+ 3 - 7
templates/job-ready.html

@@ -6,12 +6,8 @@
 {% block main %}
 job ready
 
-<p>I am a job {{ job.id }}</p>
-<p>My uuid is {{ job.task_uuid }}</p>
-<p>I was created {{ job.created }}</p>
-<p>I was finished {{ job.finished }}</p>
-<p>I will expire {{ job.expires }}</p>
-<p>My pic is: {{ job.pic_name }}</p>
-<p>My mp3 is: {{ job.mp3_name }}</p>
+{% if config["DEBUG"] %}
+{% include 'job-info.html' %}
+{% endif %}
 
 {% endblock %}