Skip to content

Commit

Permalink
[146] Add template filter argument for current time
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinHeist committed Dec 4, 2024
1 parent aff985b commit ed5a910
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
20 changes: 16 additions & 4 deletions app/models/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,22 @@

"""Supported Argument keywords."""
ARGUMENT_KEYS = (
'Series Name', 'Series Year', 'Number of Seasons', 'Series Library Names',
'Series Logo', 'Episode Watched Status', 'Season Number', 'Episode Number',
'Absolute Number', 'Episode Identifier', 'Episode Title',
'Episode Title Length', 'Episode Airdate', 'Episode Extras',
'Absolute Number',
'Current Time',
'Episode Airdate',
'Episode Extras',
'Episode Identifier',
'Episode Number',
'Episode Title',
'Episode Title Length',
'Episode Watched Status',
'Number of Seasons',
'Reference File',
'Series Library Names',
'Series Logo',
'Series Name',
'Season Number',
'Series Year',
)

"""
Expand Down Expand Up @@ -302,6 +313,7 @@ def meets_filter_criteria(self,
# Arguments for this Series and Episode
library_names = [library['name'] for library in series.libraries]
SERIES_ARGUMENTS = {
'Current Time': datetime.now(),
'Series Name': series.name,
'Series Year': series.year,
'Series Library Names': library_names,
Expand Down
44 changes: 42 additions & 2 deletions app/templates/cardTemplates.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,55 @@
<input name="argument" type="hidden">
<i class="dropdown icon"></i>
<div class="default text">Select Argument</div>
<div class="menu"><!-- Added asynchronously --></div>
<div class="menu">
<div class="item" data-value="Absolute Number">Absolute Number</div>
<div class="item" data-value="Current Time">Current Time</div>
<div class="item" data-value="Episode Airdate">Episode Airdate</div>
<div class="item" data-value="Episode Extras">Episode Extras</div>
<div class="item" data-value="Episode Identifier">Episode Identifier</div>
<div class="item" data-value="Episode Number">Episode Number</div>
<div class="item" data-value="Episode Title">Episode Title</div>
<div class="item" data-value="Episode Title Length">Episode Title Length</div>
<div class="item" data-value="Episode Watched Status">Episode Watched Status</div>
<div class="item" data-value="Number of Seasons">Number of Seasons</div>
<div class="item" data-value="Reference File">Reference File</div>
<div class="item" data-value="Series Library Names">Series Library Names</div>
<div class="item" data-value="Series Logo">Series Logo</div>
<div class="item" data-value="Series Name">Series Name</div>
<div class="item" data-value="Season Number">Season Number</div>
<div class="item" data-value="Series Year">Series Year</div>
</div>
</div>
</div>
<div class="ui field">
<div class="ui clearable selection dropdown" data-value="filter-operators">
<input name="operation" type="hidden">
<i class="dropdown icon"></i>
<div class="default text">Select Operation</div>
<div class="menu"><!-- Added asynchronously --></div>
<div class="menu">
<div class="item" data-value="is true">is true</div>
<div class="item" data-value="is false">is false</div>
<div class="item" data-value="is null">is null</div>
<div class="item" data-value="is is not null">is is not null</div>
<div class="item" data-value="equals">equals</div>
<div class="item" data-value="does not equal">does not equal</div>
<div class="item" data-value="starts with">starts with</div>
<div class="item" data-value="does not start with">does not start with</div>
<div class="item" data-value="ends with">ends with</div>
<div class="item" data-value="does not end with">does not end with</div>
<div class="item" data-value="contains">contains</div>
<div class="item" data-value="does not contain">does not contain</div>
<div class="item" data-value="matches">matches</div>
<div class="item" data-value="does not match">does not match</div>
<div class="item" data-value="is less than">is less than</div>
<div class="item" data-value="is less than or equal">is less than or equal</div>
<div class="item" data-value="is greater than">is greater than</div>
<div class="item" data-value="is greater than or equal">is greater than or equal</div>
<div class="item" data-value="is before">is before</div>
<div class="item" data-value="is after">is after</div>
<div class="item" data-value="file exists">file exists</div>
<div class="item" data-value="file does not exist">file does not exist</div>
</div>
</div>
</div>
<div class="ui field">
Expand Down
14 changes: 12 additions & 2 deletions docs/user_guide/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ reference value.

=== "Episode Airdate"

All airdate reference values must be entered as `YYYY-MM-DD` - e.g.
`2023-12-30`.
All time reference values must be entered as `YYYY-MM-DD` - e.g.
`2023-12-30` for December 30th, 2023.

| Operation | Description | Reference Value |
| --------: | :---------- | :-------------: |
Expand All @@ -319,6 +319,16 @@ reference value.
| is before | Only apply to Episodes which aired before the given date | :fontawesome-regular-circle-check:{.green} |
| is after | Only apply to Episodes which aired after the given date | :fontawesome-regular-circle-check:{.green} |

=== "Current Time"

All time reference values must be entered as `YYYY-MM-DD` - e.g.
`2023-12-30` for December 30th, 2023.

| Operation | Description | Reference Value |
| --------: | :---------- | :-------------: |
| is before | Only apply before the given date | :fontawesome-regular-circle-check:{.green} |
| is after | Only apply after the given date | :fontawesome-regular-circle-check:{.green} |

=== "Episode Extras"

| Operation | Description | Reference Value |
Expand Down
2 changes: 1 addition & 1 deletion modules/ref/version_webui
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0-alpha.13.0-webui145
v2.0-alpha.13.0-webui146

0 comments on commit ed5a910

Please sign in to comment.