diff --git a/app/config.py b/app/config.py
index 4971f9e..07e1199 100644
--- a/app/config.py
+++ b/app/config.py
@@ -10,6 +10,7 @@ class Config(object):
DISPLAY_SQL = False
ERRORS_FROM = ['noreply@midnighthax.com']
ERRORS_TO = ['kae@midnighthax.com']
+ FOLLOWED_COLOUR = '#8ae234'
LOG_LEVEL_STDERR = logging.ERROR
LOG_LEVEL_SYSLOG = logging.DEBUG
LOG_NAME = "urma"
@@ -18,3 +19,4 @@ class Config(object):
MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com"
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
+ NORMAL_COLOUR = "#f6f5f4"
diff --git a/app/helpers.py b/app/helpers.py
index b399fc2..4795712 100644
--- a/app/helpers.py
+++ b/app/helpers.py
@@ -2,6 +2,7 @@ import os
import smtplib
import ssl
+from config import Config
from email.message import EmailMessage
from config import Config
@@ -9,6 +10,8 @@ from log import log
from typing import Any, List
+from PyQt5.QtWidgets import QMessageBox
+
def ask_yes_no(title: str, question: str) -> bool:
"""Ask question; return True for yes, False for no"""
@@ -18,6 +21,21 @@ def ask_yes_no(title: str, question: str) -> bool:
return button_reply == QMessageBox.Yes
+def format_username(account) -> str:
+ """
+ Format account username according to whether we follow that account
+ or not.
+ """
+
+ username = account.username
+ if account.followed:
+ colour = Config.FOLLOWED_COLOUR
+ else:
+ colour = Config.NORMAL_COLOUR
+
+ return '' + username + ''
+
+
def index_ojects_by_parameter(object_list: List, param: Any):
"""
Create a dictionary from passed list where each list entry is keyed
diff --git a/app/models.py b/app/models.py
index 98cd6eb..22cf262 100644
--- a/app/models.py
+++ b/app/models.py
@@ -4,7 +4,7 @@ import os.path
from dbconfig import Session, scoped_session
-from typing import List
+from typing import List, Optional
from sqlalchemy import (
Boolean,
@@ -47,8 +47,8 @@ class Accounts(Base):
def __repr__(self) -> str:
return (
- f""
+ f""
)
def __init__(self, session: Session, account_id: str) -> None:
@@ -212,8 +212,8 @@ class Posts(Base):
account_id = Column(Integer, ForeignKey('accounts.id'), nullable=True)
account = relationship("Accounts", back_populates="posts")
- reblog = relationship("Posts")
- child_id = Column(Integer, ForeignKey("posts.id"))
+ reblogged_by_post = relationship("Posts")
+ boosted_post_id = Column(Integer, ForeignKey("posts.id"))
media_attachments = relationship("Attachments")
@@ -232,6 +232,43 @@ class Posts(Base):
session.add(self)
session.commit()
+ @classmethod
+ def get_unrated_before(cls, session: Session,
+ post_id: int) -> Optional["Posts"]:
+ """
+ Return latest unrated Posts object before past post_id, or None
+ if there isn't one.
+ """
+
+ return (
+ session.scalars(
+ select(cls)
+ .where(
+ (cls.rating.is_(None)),
+ (cls.post_id < post_id)
+ )
+ .order_by(cls.post_id.desc())
+ .limit(1)
+ ).first()
+ )
+
+ @classmethod
+ def get_unrated_newest(cls, session: Session) -> Optional["Posts"]:
+ """
+ Return most recent Posts object that has not been rated and which
+ is not a boosted post, or None if there isn't one.
+ """
+
+ print("get_unrated_newest")
+ return (
+ session.scalars(
+ select(cls)
+ .where(cls.rating.is_(None))
+ .order_by(cls.post_id.desc())
+ .limit(1)
+ ).first()
+ )
+
@classmethod
def get_or_create(cls, session: Session, post_id: str) -> "Posts":
"""
@@ -250,21 +287,6 @@ class Posts(Base):
return rec
- @classmethod
- def get_unrated_posts(cls, session: Session) -> List["Posts"]:
- """
- Return a list of Posts object that have not been rated
- """
-
- records = (
- session.execute(
- select(cls)
- .where(cls.rating.is_(None))
- ).scalars().all()
- )
-
- return records
-
class PostTags(Base):
__tablename__ = 'post_tags'
diff --git a/app/ui/main_window.ui b/app/ui/main_window.ui
index 1f85129..1378cea 100644
--- a/app/ui/main_window.ui
+++ b/app/ui/main_window.ui
@@ -26,7 +26,7 @@
10
90
351
- 681
+ 671
@@ -56,10 +56,10 @@ p, li { white-space: pre-wrap; }
- 20
+ 10
770
351
- 191
+ 201
@@ -74,6 +74,9 @@ p, li { white-space: pre-wrap; }
+
+ true
+
@@ -104,7 +107,7 @@ p, li { white-space: pre-wrap; }
10
0
361
- 31
+ 29
@@ -124,6 +127,9 @@ p, li { white-space: pre-wrap; }
13
+
+ color:rgb(154, 153, 150)
+
QFrame::NoFrame
@@ -141,12 +147,107 @@ p, li { white-space: pre-wrap; }
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#5e5c64;">Boosted by</span><span style=" color:#f6f5f4;"> Jon</span> <span style=" color:#8ae234;">Baker</span></p></body></html>
-
+
10
+ 60
+ 361
+ 29
+
+
+
+
+ 0
+ 29
+
+
+
+
+ 16777215
+ 29
+
+
+
+ color: rgb(119, 118, 123);
+
+
+ @JonBaker@mastodon.xyz
+
+
+
+
+
+ 10
+ 30
+ 361
+ 29
+
+
+
+
+ 0
+ 29
+
+
+
+
+ 16777215
+ 29
+
+
+
+ QFrame::NoFrame
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans'; font-size:13pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#f6f5f4;">Jon</span> <span style=" color:#8ae234;">Baker</span></p></body></html>
+
+
+
+
+
+ 366
+ 90
+ 2
+ 871
+
+
+
+ background-color: rgb(119, 118, 123);
+
+
+ Qt::Vertical
+
+
+
+
+
+ 390
+ 10
+ 311
+ 21
+
+
+
+ color: rgb(255, 255, 255);
+
+
+
+
+
+
+
+
+ 11
980
- 701
+ 692
63
@@ -382,85 +483,6 @@ p, li { white-space: pre-wrap; }
-
-
-
- 10
- 60
- 361
- 29
-
-
-
-
- 0
- 29
-
-
-
-
- 16777215
- 29
-
-
-
- color: rgb(119, 118, 123);
-
-
- @JonBaker@mastodon.xyz
-
-
-
-
-
- 10
- 30
- 361
- 29
-
-
-
-
- 0
- 29
-
-
-
-
- 16777215
- 29
-
-
-
- QFrame::NoFrame
-
-
- Qt::ScrollBarAlwaysOff
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans'; font-size:13pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#f6f5f4;">Jon</span> <span style=" color:#8ae234;">Baker</span></p></body></html>
-
-
-
-
-
- 366
- 90
- 2
- 871
-
-
-
- background-color: rgb(119, 118, 123);
-
-
- Qt::Vertical
-
-