feat(backend): Minor linting, bulk URL import, and improve BG tasks (#760)

* Fixes #751

* Fixes not showing original URL

* start slice at 0 instead of 1

* remove print statements

* add linter for print statements and remove print

* hide all buttons when edit disabled

* add bulk import API

* update attribute bindings

* unify button styles

* bulk add recipe feature

* thanks linter!

* uncomment code

Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-10-28 19:28:33 -08:00
committed by GitHub
parent 1e5ef28f91
commit 2afaf70a03
24 changed files with 295 additions and 65 deletions

View File

@@ -37,6 +37,7 @@ class CrudHttpMixins(Generic[C, R, U], ABC):
self.item = self.dal.create(data)
except Exception as ex:
logger.exception(ex)
self.session.rollback()
msg = default_msg
if exception_msgs:

View File

@@ -73,14 +73,3 @@ class EmailService(BaseService):
button_text="Test Email",
)
return self.send_email(address, test_email)
def main():
print("Starting...")
service = EmailService()
service.send_test_email("hay-kot@pm.me")
print("Finished...")
if __name__ == "__main__":
main()

View File

@@ -19,7 +19,7 @@ replace_abbreviations = {
def replace_common_abbreviations(string: str) -> str:
for k, v in replace_abbreviations.items():
regex = rf"(?<=\d)\s?({k}s?)"
regex = rf"(?<=\d)\s?({k}\bs?)"
string = re.sub(regex, v, string)
return string

View File

@@ -43,13 +43,9 @@ def clean_string(text: str) -> str:
if isinstance(text, list):
text = text[0]
print(type(text))
if text == "" or text is None:
return ""
print(text)
cleaned_text = html.unescape(text)
cleaned_text = re.sub("<[^<]+?>", "", cleaned_text)
cleaned_text = re.sub(" +", " ", cleaned_text)
@@ -201,9 +197,10 @@ def clean_time(time_entry):
if time_entry is None:
return None
elif isinstance(time_entry, timedelta):
pretty_print_timedelta(time_entry)
return pretty_print_timedelta(time_entry)
elif isinstance(time_entry, datetime):
print(time_entry)
pass
# print(time_entry)
elif isinstance(time_entry, str):
try:
time_delta_object = parse_duration(time_entry)