⚗️ add milestone event

This commit is contained in:
yanyongyu 2021-08-20 01:12:07 +08:00
parent d2dfcc9038
commit 38a41c501e
5 changed files with 168 additions and 11 deletions

View File

@ -4,7 +4,7 @@
@Author : yanyongyu
@Date : 2021-03-11 16:57:04
@LastEditors : yanyongyu
@LastEditTime : 2021-07-02 17:55:01
@LastEditTime : 2021-08-20 01:10:46
@Description : None
@GitHub : https://github.com/yanyongyu
"""
@ -24,12 +24,13 @@ from .timeline import (
TimelineEvent, TimelineEventCommited, TimelineEventForcePushed,
TimelineEventHeadDeleted, TimelineEventReferenced, TimelineEventCommented,
TimelineEventCommentDeleted, TimelineEventMentioned,
TimelineEventSubscribed, TimelineEventReviewed,
TimelineEventSubscribed, TimelineEventUnsubscribed, TimelineEventReviewed,
TimelineEventReviewRequested, TimelineEventReviewRemoved,
TimelineEventReviewDismissed, TimelineEventRenamed, TimelineEventLabeled,
TimelineEventUnlabeled, TimelineEventMerged, TimelineEventClosed,
TimelineEventAddedToProject, TimelineEventMovedColumnsInProject,
TimelineEventRemovedFromProject)
TimelineEventRemovedFromProject, TimelineEventMilestoned,
TimelineEventDemilestoned)
class IssuePullRequest(_BaseModel):
@ -101,13 +102,15 @@ class Issue(BaseModel):
TimelineEventHeadDeleted, TimelineEventReferenced,
TimelineEventCommented, TimelineEventCommentDeleted,
TimelineEventMentioned, TimelineEventSubscribed,
TimelineEventReviewed, TimelineEventReviewRequested,
TimelineEventReviewRemoved, TimelineEventReviewDismissed,
TimelineEventRenamed, TimelineEventLabeled,
TimelineEventUnlabeled, TimelineEventMerged,
TimelineEventClosed, TimelineEventAddedToProject,
TimelineEventUnsubscribed, TimelineEventReviewed,
TimelineEventReviewRequested, TimelineEventReviewRemoved,
TimelineEventReviewDismissed, TimelineEventRenamed,
TimelineEventLabeled, TimelineEventUnlabeled,
TimelineEventMerged, TimelineEventClosed,
TimelineEventAddedToProject,
TimelineEventMovedColumnsInProject,
TimelineEventRemovedFromProject, TimelineEvent],
TimelineEventRemovedFromProject, TimelineEventMilestoned,
TimelineEventDemilestoned, TimelineEvent],
self.requester,
"GET",
self.timeline_url,

View File

@ -4,7 +4,7 @@
@Author : yanyongyu
@Date : 2021-05-14 00:57:33
@LastEditors : yanyongyu
@LastEditTime : 2021-06-08 19:59:24
@LastEditTime : 2021-08-20 00:46:20
@Description : None
@GitHub : https://github.com/yanyongyu
"""
@ -21,10 +21,12 @@ from . import BaseModel
from .user import User, Actor
# Base Timeline Event
class TimelineEvent(BaseModel):
event: str
# Commit Timeline Event
class TimelineEventCommitedUser(_BaseModel):
name: str
email: str
@ -63,6 +65,7 @@ class TimelineEventCommited(TimelineEvent):
verification: TimelineEventCommitedVerification
# Force Push
class TimelineEventForcePushed(TimelineEvent):
event: Literal["head_ref_force_pushed"]
id: int
@ -74,6 +77,7 @@ class TimelineEventForcePushed(TimelineEvent):
created_at: datetime
# Head Ref Deleted
class TimelineEventHeadDeleted(TimelineEvent):
event: Literal["head_ref_deleted"]
id: int
@ -85,6 +89,7 @@ class TimelineEventHeadDeleted(TimelineEvent):
created_at: datetime
# Issue Referenced
class TimelineEventReferenced(TimelineEvent):
event: Literal["referenced"]
id: int
@ -96,6 +101,7 @@ class TimelineEventReferenced(TimelineEvent):
created_at: datetime
# Issue Commented
class TimelineEventCommented(TimelineEvent):
event: Literal["commented"]
id: int
@ -113,6 +119,7 @@ class TimelineEventCommented(TimelineEvent):
actor: Actor
# Issue Comment Deleted
class TimelineEventCommentDeleted(TimelineEvent):
event: Literal["comment_deleted"]
id: int
@ -124,6 +131,7 @@ class TimelineEventCommentDeleted(TimelineEvent):
created_at: datetime
# Issue Mentioned Person
class TimelineEventMentioned(TimelineEvent):
event: Literal["mentioned"]
id: int
@ -135,6 +143,7 @@ class TimelineEventMentioned(TimelineEvent):
created_at: datetime
# Person Subscribed/Unsubscribed Issue
class TimelineEventSubscribed(TimelineEvent):
event: Literal["subscribed"]
id: int
@ -146,6 +155,18 @@ class TimelineEventSubscribed(TimelineEvent):
created_at: datetime
class TimelineEventUnsubscribed(TimelineEvent):
event: Literal["unsubscribed"]
id: int
node_id: str
url: str
actor: Actor
commit_id: Optional[str]
commit_url: Optional[str]
created_at: datetime
# Pull Request Reviewed
class TimelineEventReviewedLink(_BaseModel):
href: str
@ -172,6 +193,7 @@ class TimelineEventReviewed(TimelineEvent):
links: TimelineEventReviewedLinks = Field(alias="_links")
# Pull Request Review Requested
class TimelineEventReviewRequested(TimelineEvent):
event: Literal["review_requested"]
id: int
@ -185,6 +207,7 @@ class TimelineEventReviewRequested(TimelineEvent):
requested_reviewer: User
# Pull Request Review Removed
class TimelineEventReviewRemoved(TimelineEvent):
event: Literal["review_request_removed"]
id: int
@ -198,6 +221,7 @@ class TimelineEventReviewRemoved(TimelineEvent):
requested_reviewer: User
# Pull Request Review Dismissed
class TimelineEventReviewDismissedInfo(_BaseModel):
state: str
review_id: int
@ -217,6 +241,7 @@ class TimelineEventReviewDismissed(TimelineEvent):
dismissed_review: TimelineEventReviewDismissedInfo
# Issue Title Renamed
class TimelineEventRenamedDetail(_BaseModel):
to: str
from_: str = Field(alias="from")
@ -234,6 +259,7 @@ class TimelineEventRenamed(TimelineEvent):
rename: TimelineEventRenamedDetail
# Issue Labeled/Unlabeled
class TimelineEventLabelInfo(_BaseModel):
name: str
color: str
@ -263,6 +289,7 @@ class TimelineEventUnlabeled(TimelineEvent):
label: TimelineEventLabelInfo
# Pull Request Merged
class TimelineEventMerged(TimelineEvent):
event: Literal["merged"]
id: int
@ -274,6 +301,7 @@ class TimelineEventMerged(TimelineEvent):
created_at: datetime
# Issue Closed
class TimelineEventClosed(TimelineEvent):
event: Literal["closed"]
id: int
@ -285,6 +313,7 @@ class TimelineEventClosed(TimelineEvent):
created_at: datetime
# Issue Added to Project
class TimelineEventAddedToProject(TimelineEvent):
event: Literal["added_to_project"]
id: int
@ -296,6 +325,7 @@ class TimelineEventAddedToProject(TimelineEvent):
created_at: datetime
# Issue Moved Columns in Project
class TimelineEventMovedColumnsInProject(TimelineEvent):
event: Literal["moved_columns_in_project"]
id: int
@ -307,6 +337,7 @@ class TimelineEventMovedColumnsInProject(TimelineEvent):
created_at: datetime
# Issue Removed from Project
class TimelineEventRemovedFromProject(TimelineEvent):
event: Literal["removed_from_project"]
id: int
@ -318,4 +349,33 @@ class TimelineEventRemovedFromProject(TimelineEvent):
created_at: datetime
# Issue Added to/Removed from Milestone
class TimelineEventMilestonedDetail(_BaseModel):
title: str
class TimelineEventMilestoned(TimelineEvent):
event: Literal["milestoned"]
id: int
node_id: str
url: str
actor: Actor
commit_id: Optional[str]
commit_url: Optional[str]
created_at: datetime
milestone: TimelineEventMilestonedDetail
class TimelineEventDemilestoned(TimelineEvent):
event: Literal["demilestoned"]
id: int
node_id: str
url: str
actor: Actor
commit_id: Optional[str]
commit_url: Optional[str]
created_at: datetime
milestone: TimelineEventMilestonedDetail
# TODO: other events

View File

@ -0,0 +1,44 @@
<!--
* @Author : yanyongyu
* @Date : 2021-08-20 00:47:57
* @LastEditors : yanyongyu
* @LastEditTime : 2021-08-20 00:59:03
* @Description : None
* @GitHub : https://github.com/yanyongyu
-->
<div class="TimelineItem">
<div class="TimelineItem-badge">
<svg
aria-hidden="true"
height="16"
viewBox="0 0 16 16"
version="1.1"
width="16"
data-view-component="true"
class="octicon octicon-milestone"
>
<path
fill-rule="evenodd"
d="M7.75 0a.75.75 0 01.75.75V3h3.634c.414 0 .814.147 1.13.414l2.07 1.75a1.75 1.75 0 010 2.672l-2.07 1.75a1.75 1.75 0 01-1.13.414H8.5v5.25a.75.75 0 11-1.5 0V10H2.75A1.75 1.75 0 011 8.25v-3.5C1 3.784 1.784 3 2.75 3H7V.75A.75.75 0 017.75 0zm0 8.5h4.384a.25.25 0 00.161-.06l2.07-1.75a.25.25 0 000-.38l-2.07-1.75a.25.25 0 00-.161-.06H2.75a.25.25 0 00-.25.25v3.5c0 .138.112.25.25.25h5z"
></path>
</svg>
</div>
<div class="TimelineItem-body">
<a class="d-inline-block">
<img
class="avatar avatar-user"
height="20"
width="20"
src="{{ event.actor.avatar_url }}"
/>
</a>
<a class="author Link--primary text-bold">
{{ event.actor.login|escape }}
</a>
removed this from the
<a class="Link--primary text-bold">{{ event.milestone.title|escape }}</a>
milestone
<a class="Link--secondary">{{ event.created_at|relative_time }}</a>
</div>
</div>

View File

@ -2,7 +2,7 @@
* @Author : yanyongyu
* @Date : 2021-05-14 17:11:26
* @LastEditors : yanyongyu
* @LastEditTime : 2021-06-08 19:49:53
* @LastEditTime : 2021-08-20 00:53:29
* @Description : None
* @GitHub : https://github.com/yanyongyu
-->
@ -78,6 +78,12 @@
{% elif event|classname == "TimelineEventRemovedFromProject" -%}
{% include "remove-from-project.html" %}
{% elif event|classname == "TimelineEventMilestoned" -%}
{% include "milestoned.html" %}
{% elif event|classname == "TimelineEventDemilestoned" -%}
{% include "demilestoned.html" %}
{% elif event|classname == "TimelineEventMerged" -%}
{% include "merge.html" %}
{% if loop.nextitem|classname == "TimelineEventClosed" -%}

View File

@ -0,0 +1,44 @@
<!--
* @Author : yanyongyu
* @Date : 2021-08-20 00:47:57
* @LastEditors : yanyongyu
* @LastEditTime : 2021-08-20 00:52:26
* @Description : None
* @GitHub : https://github.com/yanyongyu
-->
<div class="TimelineItem">
<div class="TimelineItem-badge">
<svg
aria-hidden="true"
height="16"
viewBox="0 0 16 16"
version="1.1"
width="16"
data-view-component="true"
class="octicon octicon-milestone"
>
<path
fill-rule="evenodd"
d="M7.75 0a.75.75 0 01.75.75V3h3.634c.414 0 .814.147 1.13.414l2.07 1.75a1.75 1.75 0 010 2.672l-2.07 1.75a1.75 1.75 0 01-1.13.414H8.5v5.25a.75.75 0 11-1.5 0V10H2.75A1.75 1.75 0 011 8.25v-3.5C1 3.784 1.784 3 2.75 3H7V.75A.75.75 0 017.75 0zm0 8.5h4.384a.25.25 0 00.161-.06l2.07-1.75a.25.25 0 000-.38l-2.07-1.75a.25.25 0 00-.161-.06H2.75a.25.25 0 00-.25.25v3.5c0 .138.112.25.25.25h5z"
></path>
</svg>
</div>
<div class="TimelineItem-body">
<a class="d-inline-block">
<img
class="avatar avatar-user"
height="20"
width="20"
src="{{ event.actor.avatar_url }}"
/>
</a>
<a class="author Link--primary text-bold">
{{ event.actor.login|escape }}
</a>
added this to the
<a class="Link--primary text-bold">{{ event.milestone.title|escape }}</a>
milestone
<a class="Link--secondary">{{ event.created_at|relative_time }}</a>
</div>
</div>