コード例 #1
0
class RFWMilestoneClaimSchema(ma.Schema):
    class Meta:
        additional = ("id", "stage", "stage_message", "stage_url")

    date_created = UnixDate(attribute='date_created')
    stage_change_date = UnixDate(attribute='stage_change_date')
    worker = ma.Nested("RFWWorkerSchema", exclude=['claims', 'rfw'])
    milestone = ma.Nested("RFWMilestoneSchema", exclude=['claims', 'rfw'])
コード例 #2
0
class RFWWorkerSchema(ma.Schema):
    class Meta:
        additional = ("id", "status", "status_message", "is_self")

    date_created = UnixDate(attribute='date_created')
    status_change_date = UnixDate(attribute='status_change_date')
    rfw = ma.Nested("RFWSchema", exclude=['workers', 'milestones'])
    user = ma.Nested("UserSchema")  # , exclude=['rfws'])
    claims = ma.Nested("RFWMilestoneClaimSchema",
                       many=True,
                       exclude=['worker'])
コード例 #3
0
ファイル: models.py プロジェクト: urbit/grants
class CommentSchema(ma.Schema):
    class Meta:
        model = Comment
        # Fields to expose
        fields = (
            "id",
            "proposal_id",
            "author",
            "content",
            "parent_comment_id",
            "date_created",
            "replies",
            "reported",
            "hidden",
        )

    content = ma.Method("get_content")
    date_created = UnixDate(attribute='date_created')
    author = ma.Nested("UserSchema")
    # custome handling of replies, was: replies = ma.Nested("CommentSchema", many=True)
    replies = ma.Method("get_replies")

    def get_content(self, obj):
        return HIDDEN_CONTENT if obj.hidden else obj.content

    # filter out "dead" comments
    def get_replies(self, obj):
        return comments_schema.dump(filter_dead(obj.replies))
コード例 #4
0
ファイル: models.py プロジェクト: urbit/grants
class AdminCommentSchema(ma.Schema):
    class Meta:
        model = Comment
        fields = (
            "id",
            "user_id",
            "author",
            "proposal",
            "proposal_id",
            "content",
            "date_created",
            "reported",
            "hidden",
        )

    proposal = ma.Nested("ProposalSchema", only=["id", "title", "brief"])
    author = ma.Nested("SelfUserSchema",
                       only=[
                           "id",
                           "email_address",
                           "display_name",
                           "title",
                           "avatar",
                           "azimuth",
                       ])
    date_created = UnixDate(attribute='date_created')
コード例 #5
0
ファイル: models.py プロジェクト: urbit/grants
class UserCommentSchema(ma.Schema):
    class Meta:
        model = Comment
        fields = (
            "id",
            "proposal",
            "content",
            "date_created",
            "reported",
            "hidden",
        )

    proposal = ma.Nested("ProposalSchema",
                         exclude=[
                             "team",
                             "milestones",
                             "content",
                             "invites",
                             "updates",
                         ])

    content = ma.Method("get_content")
    date_created = UnixDate(attribute='date_created')

    def get_content(self, obj):
        return HIDDEN_CONTENT if obj.hidden else obj.content
コード例 #6
0
class HistoryEventSchema(ma.Schema):
    class Meta:
        model = HistoryEvent
        # Fields to expose
        fields = ("id", "title", "title_raw", "content", "content_raw", "date",
                  "user", "proposal")

    date = UnixDate(attribute="date")
    user = ma.Nested("UserSchema")
    proposal = ma.Nested("ProposalSchema")
    title = ma.Method("text_title")
    title_raw = ma.Method("raw_title")
    content = ma.Method("markdown_content")
    content_raw = ma.Method("raw_content")

    def text_title(self, obj):
        return make_text(obj, "title")

    def raw_title(self, obj):
        return obj.title

    def raw_content(self, obj):
        return obj.content

    def markdown_content(self, obj):
        return make_markdown(obj, "content")
コード例 #7
0
class RFWSchema(ma.Schema):
    class Meta:
        additional = (
            "id",
            "title",
            "brief",
            "content",
            "status",
            "category",
            "bounty",  # derived from ms
            "effort_from",  # derived from ms
            "effort_to",  # derived from ms
        )

    date_created = UnixDate(attribute='date_created')
    status_change_date = UnixDate(attribute='status_change_date')
    workers = ma.Nested("RFWWorkerSchema", many=True, exclude=['rfw'])
    authed_worker = ma.Nested("RFWWorkerSchema", exclude=['rfw'])
    milestones = ma.Nested("RFWMilestoneSchema", many=True, exclude=['rfw'])
    tags = ma.Nested("TagSchema", many=True)
コード例 #8
0
class RFWMilestoneSchema(ma.Schema):
    class Meta:
        additional = ("id", "index", "title", "content", "effort_from",
                      "effort_to", "bounty", "is_authed_active")

    date_created = UnixDate(attribute='date_created')
    rfw = ma.Nested("RFWSchema")
    claims = ma.Nested("RFWMilestoneClaimSchema",
                       many=True,
                       exclude=['milestone'])
    authed_claim = ma.Nested("RFWMilestoneClaimSchema", exclude=['milestone'])
コード例 #9
0
ファイル: models.py プロジェクト: urbit/grants
class MilestoneSchema(ma.Schema):
    class Meta:
        model = Milestone
        # Fields to expose
        fields = (
            "title",
            "index",
            "id",
            "content",
            "stage",
            "payout_amount",
            "immediate_payout",
            "reject_reason",
            "paid_tx_id",
            "date_created",
            "date_estimated",
            "date_requested",
            "date_rejected",
            "date_accepted",
            "date_paid",
        )

    date_created = UnixDate(attribute='date_created')
    date_estimated = UnixDate(attribute='date_estimated')
    date_requested = UnixDate(attribute='date_requested')
    date_rejected = UnixDate(attribute='date_rejected')
    date_accepted = UnixDate(attribute='date_accepted')
    date_paid = UnixDate(attribute='date_paid')
コード例 #10
0
class AdminLogSchema(ma.Schema):
    class Meta:
        model = AdminLog
        # Fields to expose
        fields = (
            "id",
            "date_created",
            "event",
            "message",
            "user",
            "ip",
        )

    date_created = UnixDate(attribute="date_created")
    user = ma.Nested("UserSchema")