---
config:
    layout: elk
---

classDiagram
    %% 模型类
    class BlogUser {
        +String nickname
        +DateTime creation_time
        +DateTime last_modify_time
        +String source
        +get_absolute_url()
        +get_full_url()
    }

    %% 表单类
    class BlogUserCreationForm {
        +CharField password1
        +CharField password2
        +clean_password2()
        +save()
    }

    class BlogUserChangeForm {
        +__init__()
    }

    class LoginForm {
        +__init__()
    }

    class RegisterForm {
        +__init__()
        +clean_email()
    }

    class ForgetPasswordForm {
        +CharField new_password1
        +CharField new_password2
        +EmailField email
        +CharField code
        +clean_new_password2()
        +clean_email()
        +clean_code()
    }

    class ForgetPasswordCodeForm {
        +EmailField email
    }

    %% 视图类
    class RegisterView {
        +form_valid()
    }

    class LogoutView {
        +get()
    }

    class LoginView {
        +get_context_data()
        +form_valid()
        +get_success_url()
    }

    class ForgetPasswordView {
        +form_valid()
    }

    class ForgetPasswordEmailCode {
        +post()
    }

    %% 认证后端
    class EmailOrUsernameModelBackend {
        +authenticate()
        +get_user()
    }

    %% 应用配置
    class AccountsConfig

    %% 测试类
    class AccountTest

    %% 工具函数
    class utils {
        +send_verify_email()
        +verify()
        +set_code()
        +get_code()
    }

    %% 继承关系
    BlogUser --|> AbstractUser
    BlogUserCreationForm --|> ModelForm
    BlogUserChangeForm --|> UserChangeForm
    LoginForm --|> AuthenticationForm
    RegisterForm --|> UserCreationForm
    ForgetPasswordForm --|> Form
    ForgetPasswordCodeForm --|> Form
    RegisterView --|> FormView
    LogoutView --|> RedirectView
    LoginView --|> FormView
    ForgetPasswordView --|> FormView
    ForgetPasswordEmailCode --|> View
    EmailOrUsernameModelBackend --|> ModelBackend
    AccountsConfig --|> AppConfig
    AccountTest --|> TestCase

    %% 关联关系
    BlogUserCreationForm --> BlogUser : 创建
    BlogUserChangeForm --> BlogUser : 修改
    RegisterForm --> BlogUser : 注册
    ForgetPasswordForm --> BlogUser : 重置密码
    RegisterView --> RegisterForm : 使用
    LoginView --> LoginForm : 使用
    ForgetPasswordView --> ForgetPasswordForm : 使用
    ForgetPasswordEmailCode --> ForgetPasswordCodeForm : 使用
    EmailOrUsernameModelBackend --> BlogUser : 认证
    AccountTest --> BlogUser : 测试
    AccountTest --> utils : 测试
    ForgetPasswordForm --> utils : 验证
    ForgetPasswordEmailCode --> utils : 发送邮件
    RegisterView --> utils : 发送邮件

    %% 依赖关系
    views ..> utils : 导入
    forms ..> BlogUser : 导入
    tests ..> BlogUser : 导入
    tests ..> utils : 导入
    admin ..> BlogUser : 导入