mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Swapping tag config items, sorted by tag name first will make it easier to read.
This commit is contained in:
parent
6883a4734a
commit
b85d868a1b
2 changed files with 8 additions and 3 deletions
|
|
@ -467,7 +467,7 @@ def import_channels_config():
|
|||
# video_path, so we can match the complete path for the Video.
|
||||
video_path = channel_dir / video_path
|
||||
file_group: FileGroup = FileGroup.find_by_path(video_path, session)
|
||||
if file_group.tag_files:
|
||||
if file_group and file_group.tag_files:
|
||||
# Video is already tagged or favorited.
|
||||
pass
|
||||
elif file_group:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import contextlib
|
||||
from typing import List
|
||||
|
||||
from cryptography.exceptions import InvalidTag
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, BigInteger
|
||||
from sqlalchemy.orm import relationship, Session
|
||||
|
||||
|
|
@ -96,6 +97,7 @@ class TagsConfig(ConfigFile):
|
|||
|
||||
@tags.setter
|
||||
def tags(self, value):
|
||||
value = sorted(value, key=lambda i: (i[0].lower(), i[1]))
|
||||
self.update({'tags': value})
|
||||
|
||||
def add_tag(self, tag_file: TagFile):
|
||||
|
|
@ -105,7 +107,7 @@ class TagsConfig(ConfigFile):
|
|||
tag_name = tag_file.tag.name
|
||||
tags = self.tags.copy()
|
||||
|
||||
value = [primary_path, tag_name]
|
||||
value = [tag_name, primary_path]
|
||||
if value not in tags:
|
||||
tags.append(value)
|
||||
self.tags = tags
|
||||
|
|
@ -118,7 +120,7 @@ class TagsConfig(ConfigFile):
|
|||
tags = self.tags.copy()
|
||||
|
||||
for idx, value in enumerate(self.tags):
|
||||
if value == [primary_path, tag_name]:
|
||||
if value == [tag_name, primary_path]:
|
||||
tags = tags.copy()
|
||||
tags.pop(idx)
|
||||
self.tags = tags
|
||||
|
|
@ -154,6 +156,9 @@ def get_tags(session: Session) -> List[Tag]:
|
|||
|
||||
@optional_session
|
||||
def new_tag(name: str, color: str, session: Session) -> Tag:
|
||||
if ',' in name:
|
||||
raise InvalidTag('Tag name cannot have comma')
|
||||
|
||||
tag = Tag(name=name, color=color)
|
||||
session.add(tag)
|
||||
session.flush([tag])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue