Class Diagrams - bounswe/bounswe2024group11 GitHub Wiki
classDiagram
direction LR
class Model{
+save(*args, **kwargs): NONE
+delete(*args, **kwargs): NONE
+__str__(): String
+get_absolute_url(): String
+full_clean(exclude=None, validate_unique=True): NONE
+refresh_from_db(using=None, fields=None): NONE
+get_FOO_display(): String
+prepare_database_save( field): Prepared instance
+natural_key(): Tuple
+clean(): NONE
+save_base(raw=False, using=None, force_insert=False, force_update=False, update_fields=None): NONE
+validate_unique(exclude=None): NONE
+serializable_value(field_name): Serialized field value
+_meta: Metadata(of model)
}
note for Model "The Model class is inherited by all custom model classes in this class diagram."
class ModelSerializer{
+ __init__(*args, **kwargs): NONE
+create(validated_data): MODEL
+update(instance, validated_data): MODEL
+to_representation(instance): Dictionary
+to_internal_value(data): Dictionary
+validate(attrs): Dictionary
+is_valid(raise_exception=False): Boolean
+save(**kwargs): MODEL
+run_validation(data): Dictionary
+get_fields(): Dictionary
+get_validators(): List
}
note for ModelSerializer "The ModelSerializer class is inherited by all custom serializer classes in this class diagram."
class ModelViewset{
+list(request, *args, kwargs): JSON
+retrieve(request, *args, kwargs): JSON
+create(request, *args, **kwargs): JSON
+update(request, *args, kwargs): JSON
+destroy(request, *args, **kwargs): JSON
+partial_update(request, *args, **kwargs): JSON
}
note for ModelViewset "The ModelViewSet class is inherited by all custom viewset classes in this class diagram."
class BabelNetClient {
-String api_key
-String base_url
+BabelNetClient(api_key)
+fetch_synsets(keyword: String) : JSON
+parse_response(response: JSON) : List
}
class BabelNetAPI {
+get_synsets(keyword: String, api_key: String) : JSON
}
BabelNetClient --> BabelNetAPI : sends requests to
BabelNetClient --> QuizViewset : searches
BabelNetClient --> ForumQuestionViewset : searches
User "M" --> "M" QuizViewset : makes requests
User "M" --> "M" ForumQuestionViewset : makes requests
class User{
-userController: UserController
-username: String
-password: String
}
%% write all controller functions
class UserController{
+create() User
+all(): List(User)
}
User "M" o-- "1" UserController : controls
class UserAuthenticationSerializer{
model: User
fields: all
}
class UserInfoSerializer{
model: User
exclude: password
}
User "1" *-- "1" UserInfoSerializer : serializes
User "1" *-- "1" UserAuthenticationSerializer : serializes
class UserAuthenticationViewset{
queryset: List(User)
serializer_class: UserInfoSerializer
}
class UserInfoViewset{
queryset: List(User)
serializer_class: UserAuthenticationSerializer
}
UserInfoSerializer "1" o-- "1" UserInfoViewset : uses
UserAuthenticationSerializer "1" o-- "1" UserAuthenticationViewset : uses
class Quiz{
quiz_id: String
creator_id: String
title: String
question_list: List(question_id)
quiz_tag_id: String
quiz_tag_name: String
}
%% write all controller functions
class QuizController{
+create() Quiz
+all(): List(Quiz)
}
Quiz "M" o-- "1" QuizController : controls
class QuizSerializer{
model: Quiz
fields: all
}
Quiz "1" *-- "1" QuizSerializer : serializes
class QuizViewset{
queryset: List(Quiz)
serializer_class: QuizSerializer
}
class QuizFeedViewset{
user_id: String
queryset: List(Quiz)
serializer_class: QuizSerializer
}
QuizSerializer "1" o-- "1" QuizFeedViewset : uses
QuizSerializer "1" o-- "1" QuizViewset : uses
class QuizQuestion{
question_id: String
question: String
answer: String
choices: List(String)
}
User "M" --> "M" Quiz : creates
class QuizQuestionController{
+create() QuizQuestion
+all(): List(QuizQuestion)
}
QuizQuestion "M" o-- "1" QuizQuestionController : controls
QuizQuestion "M" *-- "1" Quiz : has
class QuizQuestionSerializer{
model: QuizQuestion
fields: all
}
QuizQuestion "1" *-- "1" QuizQuestionSerializer : serializes
class QuizQuestionViewset{
queryset: List(QuizQuestion)
serializer_class: QuizQuestionSerializer
}
QuizQuestionSerializer "1" o-- "1" QuizQuestionViewset : uses
class ForumQuestion{
forumQuestion_id: String
user_id: String
content: String
tag_name: String
tag_id: String
}
class ForumQuestionController{
+create() ForumQuestion
+all(): List(ForumQuestion)
}
ForumQuestion "M" o-- "1" ForumQuestionController : controls
class ForumQuestionSerializer{
upVoteNumber: Integer
downVoteNumber: Integer
answer_list:List(forumAnswer_id)
model: ForumQuestion
fields: all
}
ForumQuestion "1" *-- "1" ForumQuestionSerializer : serializes
class ForumQuestionViewset{
queryset: List(ForumQuestion)
serializer_class: ForumQuestionSerializer
}
class ForumQuestionFeedViewset{
user_id: String
queryset: List(ForumQuestion)
serializer_class: ForumQuestionSerializer
}
ForumQuestionSerializer "1" o-- "1" ForumQuestionFeedViewset : uses
ForumQuestionSerializer "1" o-- "1" ForumQuestionViewset : uses
class ForumAnswer{
forumAnswer_id: String
user_id: String
}
class ForumAnswerController{
+create() ForumAnswer
+all(): List(ForumAnswer)
}
ForumAnswer "M" o-- "1" ForumAnswerController : controls
ForumQuestion "M" *-- "0" ForumAnswer : has
class ForumAnswerSerializer{
upVoteNumber: Integer
downVoteNumber: Integer
model: ForumAnswer
fields: all
}
ForumAnswer "1" *-- "1" ForumAnswerSerializer : serializes
class ForumAnswerViewset{
queryset: List(ForumAnswer)
serializer_class: ForumAnswerSerializer
}
ForumAnswerSerializer "1" o-- "1" ForumAnswerViewset : uses
class ForumQuestionBookmark {
user_id : String
question_id : String
}
class ForumQuestionVote{
user_id: String
question_id: String
upvote: Boolean
}
class ForumAnswerVote{
user_id: String
answer_id: String
upvote: Boolean
}
class ForumQuestionBookmarkController{
+create() ForumQuestionBookmark
+all(): List(ForumQuestionBookmark)
}
class ForumQuestionVoteController{
+create() ForumQuestionVote
+all(): List(ForumQuestionVote)
}
class ForumAnswerVoteController{
+create() ForumAnswerVote
+all(): List(ForumAnswerVote)
}
ForumQuestionBookmark "M" o-- "1" ForumQuestionBookmarkController : controls
ForumQuestionVote "M" o-- "1" ForumQuestionVoteController : controls
ForumAnswerVote "M" o-- "1" ForumAnswerVoteController : controls
User "1" *-- "M" ForumQuestionBookmark : bookmarks
User "1" *-- "M" ForumQuestionVote : votes
User "1" *-- "M" ForumAnswerVote : votes
ForumQuestion "M" *-- "M" ForumQuestionBookmark : gets bookmarked
ForumQuestion "M" *-- "M" ForumQuestionVote : gets voted
ForumQuestion "M" *-- "M" ForumAnswerVote : gets voted
class ForumQuestionBookmarkSerializer{
model: ForumQuestionBookmark
fields: all
}
class ForumQuestionVoteSerializer{
model: ForumQuestionVote
fields: all
}
ForumQuestionVote "1" *-- "1" ForumQuestionVoteSerializer : serializes
ForumQuestionBookmark "1" *-- "1" ForumQuestionBookmarkSerializer : serializes
class ForumQuestionBookmarkViewset{
queryset: List(ForumQuestionBookmark)
serializer_class: ForumQuestionBookmarkSerializer
}
class ForumQuestionVoteViewset{
queryset: List(ForumQuestionVote)
serializer_class: ForumQuestionVoteSerializer
}
ForumQuestionVoteSerializer "1" o-- "1" ForumQuestionVoteViewset : uses
ForumQuestionBookmarkSerializer "1" o-- "1" ForumQuestionBookmarkViewset : uses
class Follow{
follower_id: String
following_id: String
}
class Block{
blocker_id: String
blocked_id: String
}
class FollowController{
+create() Follow
+all(): List(Follow)
}
class BlockController{
+create() Block
+all(): List(Block)
}
Follow "M" o-- "1" FollowController : controls
Block "M" o-- "1" BlockController : controls
class FollowSerializer{
model: Follow
fields: all
}
class BlockSerializer{
model: Block
fields: all
}
Follow "1" *-- "1" FollowSerializer : serializes
Block "1" *-- "1" BlockSerializer : serializes
class ForumQuestionViewset{
queryset: List(ForumQuestion)
serializer_class: ForumQuestionSerializer
}
class FollowViewset{
queryset: List(Follow)
serializer_class: FollowSerializer
}
class BlockViewset{
queryset: List(Block)
serializer_class: BlockSerializer
}
FollowSerializer "1" o-- "1" FollowViewset : uses
BlockSerializer "1" o-- "1" BlockViewset : uses
class Router {
+route: "/quizzes/" => QuizView
+route: "/quizzes/id/" => QuizDetailView
}
class QuizView {
+list_quizzes()
+create_quiz()
}
class QuizDetailView {
+get_quiz(id)
+update_quiz(id)
+delete_quiz(id)
}
Router --> QuizView
Router --> QuizDetailView