Esempio n. 1
0
    def post(self, user_id: str) -> flask.Response:
        user_repository = container.get(UserRepository)
        feedback_create_service: FeedbackCreateService = container.get(
            FeedbackCreateService)

        user_key = UserKey.build(user_id)
        current_user = user_repository.fetch_by_key(user_key)
        if not isinstance(current_user, CustomerUser):
            raise Forbidden()

        feedback_create_service.execute(
            user=current_user,
            title=FeedbackTitle(f"作成した要望 - {utcnow_with_tz().isoformat()}"),
            description=FeedbackDescription("要望本文"),
        )

        return flask.redirect(location=flask.request.path,
                              Response=flask.Response)
Esempio n. 2
0
    def __init__(self, user_repository: UserRepository) -> None:
        self._user_repository = user_repository

        sample_feedbacks = [
            Feedback(
                key=FeedbackKey.build("f20001"),
                feedback_user=FeedbackUser.build_from_user(
                    user=self._user_repository.fetch_by_key(key=UserKey.build("c10001"))
                ),
                title=FeedbackTitle("要望サンプル"),
                description=FeedbackDescription("要望本文"),
                status=FeedbackStatus.New,
                created_at=datetime(2020, 10, 1, 10, 0, 0).astimezone(tz=timezone.utc),
            )
        ]

        self._feedbacks: Dict[FeedbackKey, Feedback] = {
            feedback.key: feedback for feedback in sample_feedbacks
        }

        self._comments: Dict[FeedbackKey, List[FeedbackComment]] = defaultdict(list)
Esempio n. 3
0
def build_feedback(
    key: Optional[FeedbackKey] = None,
    feedback_user: Union[None, User, FeedbackUser] = None,
    title: Optional[str] = None,
    description: Optional[str] = None,
    status: Optional[FeedbackStatus] = None,
    now: Optional[datetime.datetime] = None,
) -> Feedback:
    if key is None:
        key = FeedbackKey.build_new()
    if feedback_user is None:
        feedback_user = FeedbackUser.build_from_user(user=build_customer_user())
    if isinstance(feedback_user, User):
        feedback_user = FeedbackUser.build_from_user(user=feedback_user)

    return Feedback(
        key=key,
        feedback_user=feedback_user,
        title=FeedbackTitle(title or "要望のタイトル"),
        description=FeedbackDescription(description or "要望の詳細"),
        status=status or FeedbackStatus.New,
        created_at=now or utcnow_with_tz(),
    )
 def test_invalid_too_long_description(self):
     with pytest.raises(AssertionError):
         FeedbackDescription("a" * FeedbackDescription.MAX_LENGTH + "x")
 def test_invalid_empty_description(self):
     with pytest.raises(AssertionError):
         FeedbackDescription("")
 def test_valid_description(self):
     valid = FeedbackDescription("要望の本文")
     assert isinstance(valid, FeedbackDescription)
Esempio n. 7
0
# 要望一覧
feedbacks = FeedbackCollection.build([])

# 顧客「山田 太郎」としてログイン
login_user = CustomerUser.build(
    key=UserKey.build("c10001"),
    name=UserName("山田 太郎"),
    company_name=CompanyName("株式会社ラビィ"),
)

# 要望を登録する
requested_feedback = Feedback.build_new(
    user=login_user,
    title=FeedbackTitle("IE11でも動くようにして欲しい"),
    description=FeedbackDescription("会社でふだん使っているブラウザ(IE11)でも動くようにしてほしいです。"),
)
feedbacks.append(requested_feedback)

# カスタマーサポート「佐藤 次郎」としてログイン
support_user = SupportUser.build(
    key=UserKey.build("s10099"),
    name=UserName("佐藤 次郎"),
)
# カスタマーサポートの担当者が、新着の要望を確認する
new_feedbacks = feedbacks.filter_by_status(status=FeedbackStatus.New)

# 新着の要望を順に確認する (最初の要望を取り出す)
new_feedback = next(iter(new_feedbacks))
# 確認した要望のステータスを [確認済み] に変更する
accepted_feedback = new_feedback.with_status(status=FeedbackStatus.Accepted)