forked from retoor/devplacepy
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141921d7a3 |
File diff suppressed because one or more lines are too long
@@ -42,6 +42,7 @@ def init_db():
|
||||
_index(db, "posts", "idx_posts_created_at", ["created_at"])
|
||||
_index(db, "posts", "idx_posts_topic", ["topic"])
|
||||
_index(db, "posts", "idx_posts_slug", ["slug"])
|
||||
_index(db, "posts", "idx_posts_project_uid", ["project_uid"])
|
||||
if "posts" in tables:
|
||||
posts_table = get_table("posts")
|
||||
if not posts_table.has_column("tags"):
|
||||
|
||||
@@ -439,8 +439,8 @@ class VoteForm(BaseModel):
|
||||
@field_validator("value")
|
||||
@classmethod
|
||||
def valid_value(cls, value):
|
||||
if value not in (1, -1, 0):
|
||||
raise ValueError("value must be 1, -1, or 0")
|
||||
if value not in (1, -1):
|
||||
raise ValueError("value must be 1 or -1")
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -216,6 +216,15 @@ async def project_detail(request: Request, project_slug: str):
|
||||
if parent
|
||||
else None
|
||||
)
|
||||
posts_table = get_table("posts")
|
||||
project_posts = list(
|
||||
posts_table.find(
|
||||
project_uid=project["uid"],
|
||||
deleted_at=None,
|
||||
order_by=["-created_at"],
|
||||
)
|
||||
)
|
||||
|
||||
return respond(
|
||||
request,
|
||||
"project_detail.html",
|
||||
@@ -235,6 +244,7 @@ async def project_detail(request: Request, project_slug: str):
|
||||
"forked_from": forked_from,
|
||||
"fork_count": count_forks(project["uid"]),
|
||||
"file_count": count_files(project["uid"]),
|
||||
"project_posts": project_posts,
|
||||
},
|
||||
),
|
||||
model=ProjectDetailOut,
|
||||
|
||||
@@ -163,6 +163,7 @@ class ProjectDetailOut(_Out):
|
||||
forked_from: Optional[dict] = None
|
||||
fork_count: int = 0
|
||||
file_count: int = 0
|
||||
project_posts: list[PostOut] = []
|
||||
|
||||
|
||||
class GistsOut(_Out):
|
||||
|
||||
@@ -22,7 +22,7 @@ ENGAGEMENT_ACTIONS: tuple[Action, ...] = (
|
||||
),
|
||||
body(
|
||||
"value",
|
||||
"Vote value: 1 to upvote, -1 to downvote, 0 to retract.",
|
||||
"Vote value: 1 to upvote, -1 to downvote (re-send to remove).",
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -313,3 +313,50 @@
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.project-devlog {
|
||||
margin-top: 2rem;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.devlog-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.devlog-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.5rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.devlog-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.devlog-link {
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.devlog-link:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.devlog-date {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.devlog-empty {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,22 @@
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
|
||||
<div class="project-devlog">
|
||||
<h2 class="project-section-label">Devlog</h2>
|
||||
{% if project_posts %}
|
||||
<ul class="devlog-list">
|
||||
{% for post in project_posts %}
|
||||
<li class="devlog-item">
|
||||
<a href="/posts/{{ post['slug'] }}" class="devlog-link">{{ render_title(post['title']) }}</a>
|
||||
<span class="devlog-date">{{ local_dt(post['created_at'], 'date') }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="devlog-empty">No posts yet for this project.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% with target_uid=project['uid'], target_type="project" %}
|
||||
{% include "_comment_section.html" %}
|
||||
{% endwith %}
|
||||
|
||||
@@ -135,13 +135,3 @@ def test_non_ajax_vote_redirects_to_referer(app_server):
|
||||
)
|
||||
assert r.status_code == 302
|
||||
assert r.headers["location"] == "/gists"
|
||||
|
||||
|
||||
def test_explicit_zero_retracts_vote(app_server):
|
||||
s_a, a_name = _session_votes()
|
||||
s_b, _ = _session_votes()
|
||||
post_uid = _make_post_votes(_uid_votes(a_name))
|
||||
s_b.post(f"{BASE_URL}/votes/post/{post_uid}", data={"value": "1"}, headers=AJAX_votes)
|
||||
r = s_b.post(f"{BASE_URL}/votes/post/{post_uid}", data={"value": "0"}, headers=AJAX_votes)
|
||||
assert r.json()["value"] == 0
|
||||
assert r.json()["net"] == 0
|
||||
|
||||
Reference in New Issue
Block a user