Bubble [main]

Fixed issue number assignment

9943347e47e48e9561cd1e598bd7240f4b191d40
diff --git a/50_bubble.py b/50_bubble.py
index 84b55b6..edb8c1f 100644
--- a/50_bubble.py
+++ b/50_bubble.py
@@ -162,7 +162,7 @@ Bubble is open source:
             author_link = sub if sub else '/u/' + post.poster_name
 
             if is_issue_tracker:
-                src = f'=> {post.page_url()} ๐Ÿž #{post.issueid} ยท {post.title}{tag}\n'
+                src = f'=> {post.page_url()} ๐Ÿž #{post.issueid if post.issueid else 0} ยท {post.title}{tag}\n'
                 src += shorten_text(post.summary, 200) + '\n'
                 src += f'{post.poster_avatar} {post.poster_name}{cmt}{likes} ยท {age}{bell}\n'
             else:
@@ -184,7 +184,7 @@ Bubble is open source:
                 vis_title = shorten_text(clean_title(post.summary), 100)
 
             if self.is_context_tracker:
-                vis_title = f'[#{post.issueid}] ' + vis_title
+                vis_title = f'[#{post.issueid if post.issueid else 0}] ' + vis_title
 
             if not context or context.id != post.subspace:
                 author = f'{post.poster_name}: '
@@ -219,7 +219,8 @@ Bubble is open source:
             """Render the final full presentation of the post, with all segments included."""
             src = ''
             if len(post.title):
-                src += f'# {post.title}\n\n'
+                title_prefix = f'[#{post.issueid}] ' if post.issueid else ''
+                src += f'# {title_prefix}{post.title}\n\n'
 
             last_type = None
             for segment in self.db.get_segments(post, poll=False):
diff --git a/feeds.py b/feeds.py
index 6a85a0d..5a4f7c6 100644
--- a/feeds.py
+++ b/feeds.py
@@ -102,7 +102,7 @@ def make_post_page_or_configure_feed(session):
         if not session.is_context_tracker: # issues use the text as the title
             db.create_segment(post, Segment.TEXT, content=seg_text)
         db.update_post_summary(post)
-        if post.issueid != None:
+        if session.is_context_tracker:
             # Further content is required.
             return 30, f'/edit/{post.id}'
         db.publish_post(post)
diff --git a/model.py b/model.py
index 97a8421..36fcc16 100644
--- a/model.py
+++ b/model.py
@@ -885,16 +885,10 @@ class Database:
             flags = flags | Post.OMIT_FROM_FEED_FLAG
 
         cur = self.conn.cursor()
-        if subspace.flags & Subspace.ISSUE_TRACKER:
-            cur.execute("""
-                INSERT INTO posts (subspace, parent, user, title, flags, issueid)
-                VALUES (?, ?, ?, ?, ?, 0)
-            """, (subspace_id, parent, user.id, title, flags))
-        else:
-            cur.execute("""
-                INSERT INTO posts (subspace, parent, user, title, flags)
-                VALUES (?, ?, ?, ?, ?)
-            """, (subspace_id, parent, user.id, title, flags))
+        cur.execute("""
+            INSERT INTO posts (subspace, parent, user, title, flags)
+            VALUES (?, ?, ?, ?, ?)
+        """, (subspace_id, parent, user.id, title, flags))
         self.commit()
         post_id = cur.lastrowid
 
@@ -942,6 +936,7 @@ class Database:
         self.commit()
 
     def update_post_summary(self, post):
+        subspace = self.get_subspace(id=post.subspace)
         # Render a concise version of the segments to be displayed in feeds,
         # save in the `render` field.
         segments = self.get_segments(post)
@@ -956,7 +951,7 @@ class Database:
             render += f'=> {seg.url} โ€” {seg_content}\n'
             break
 
-        if len(post.title) and post.issueid is None:
+        if len(post.title) and not (subspace.flags & Subspace.ISSUE_TRACKER):
             render += post.title
             with_title = True
         else:
@@ -1010,7 +1005,8 @@ class Database:
                 self.notify_new_poll(post)
 
         if self.get_subspace(post.subspace).flags & Subspace.ISSUE_TRACKER and \
-            post.issueid == 0:
+                post.issueid is None and \
+                post.parent == 0:
             # Time to assign a new issue number.
             cur.execute("""
                 UPDATE posts