Skip to content

Commit

Permalink
fix #92 #93
Browse files Browse the repository at this point in the history
  • Loading branch information
hcwinsemius committed Jun 14, 2024
1 parent 9dd2615 commit 7e95662
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ LORC_PORT=8000
LORC_DB_DIR=lorc_data
LORC_DB_HOST=db
LORC_DB_PORT=5432
LORC_DB_USER=postgres
LORC_DB_PASS=password
LORC_DB_USER=liveorc_dbuser
LORC_DB_PASS=liveorc_dbsecret
LORC_STORAGE_DIR=lorc_media
LORC_STORAGE_HOST=http://storage
LORC_STORAGE_PORT=9000
Expand Down
5 changes: 4 additions & 1 deletion api/admin/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def toolfunc(self, request, obj):
return redirect('/admin/api/video')
elif not obj.time_series:
messages.error(request, f"Video {obj.id} does not yet have a water level at associated time stamp. ")
elif not obj.camera_config.profile:
messages.error(request, f"Video {obj.id}'s camera configuration does not have a profile. Add a profile to the camera configuration. ")
elif not obj.camera_config.recipe:
messages.error(request,f"Video {obj.id}'s camera configuration does not have a recipe. Add a recipe to the camera configuration. ")
elif obj.status == VideoStatus.QUEUE or obj.status == VideoStatus.TASK:
messages.error(request, f"Video {obj.id} is already queued or being processed. ")
return HttpResponseRedirect(reverse("admin:api_video_change", args=(obj.pk,)))


change_actions = ('toolfunc', )

ordering = ["-timestamp"]
Expand Down
27 changes: 26 additions & 1 deletion api/models/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ def thumbnail_preview(self):
def is_ready_for_task(self):
if not self.time_series:
return False
if not self.camera_config:
return False
if not (self.camera_config.recipe and self.camera_config.profile):
return False

return (self.status == VideoStatus.NEW or self.status == VideoStatus.ERROR) and self.time_series.h is not None

@property
Expand Down Expand Up @@ -311,13 +316,33 @@ def link_video(self):
return self
# return mark_safe('<img src="{}" width="{}" height="{}" />'.format(self.image.url, width, height))



# elif not obj.time_series:
# messages.error(request, f"Video {obj.id} does not yet have a water level at associated time stamp. ")
# elif not obj.camera_config.profile:
# messages.error(request, f"Video {obj.id}'s camera configuration does not have a profile. Add a profile to the camera configuration. ")
# elif not obj.camera_config.recipe:
# messages.error(request,f"Video {obj.id}'s camera configuration does not have a recipe. Add a recipe to the camera configuration. ")
# elif obj.status == VideoStatus.QUEUE or obj.status == VideoStatus.TASK:
# messages.error(request, f"Video {obj.id} is already queued or being processed. ")


@property
def play_button(self):
if self.status == VideoStatus.NEW:
if self.is_ready_for_task:
return get_task_run(self.id)
else:
return mark_safe('<i class="fa-solid fa-circle-play" style="color: #a1a1a1;"></i> Water level missing')
if not self.time_series:
queue_msg = "water level missing"
elif not self.camera_config.profile:
queue_msg = "no profile"
elif not self.camera_config.recipe:
queue_msg = "no recipe"
else:
queue_msg = "n/a"
return mark_safe(f'<i class="fa-solid fa-circle-play" style="color: #a1a1a1;"></i> {queue_msg} ')

elif self.status == VideoStatus.QUEUE:
return mark_safe(
Expand Down

0 comments on commit 7e95662

Please sign in to comment.