This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
refactor(article-tags): rewrite ...#363
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
17 commits Select commitHold shift + click to select a range
6c33b84
refactor(article-tags): wip
mydearxym640cc0f
refactor(article-tags): wip
mydearxym7084f09
refactor(article-tags): use one table to handle them all
mydearxym4449e3f
refactor(article-tags): use macro to extract
mydearxymfbbc2a7
refactor(article-tags): basic tag test
mydearxymf3a32e6
refactor(article-tags): wip
mydearxyma6570af
refactor(article-tags): wip
mydearxymeedabd7
refactor(article-tags): wip
mydearxym00299b3
refactor(article-tags): wip
mydearxym5aab9ba
refactor(article-tags): remove old tags system
mydearxym9edb5eb
refactor(article-tags): naming
mydearxym8c5d89a
refactor(article-tags): fix tests
mydearxym92128fd
refactor(article-tags): fix tests
mydearxym2edfe0c
refactor(article-tags): fix tests
mydearxym982e1dc
refactor(article-tags): add group field support
mydearxym6af8b93
refactor(article-tags): add group field support
mydearxym78729d6
refactor(article-tags): add article_tag & community filter test
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletioncover/excoveralls.json
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
16 changes: 5 additions & 11 deletionsdocs/testing/unit-testing.zh-CN.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionlib/groupher_server/accounts/delegates/collect_folder.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletionslib/groupher_server/cms/article_tag.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
defmodule GroupherServer.CMS.ArticleTag do | ||
@moduledoc false | ||
alias __MODULE__ | ||
use Ecto.Schema | ||
use Accessible | ||
import Ecto.Changeset | ||
alias GroupherServer.CMS | ||
alias CMS.{Author, Community} | ||
@required_fields ~w(thread title color author_id community_id)a | ||
@updatable_fields ~w(thread title color community_id group)a | ||
@type t :: %ArticleTag{} | ||
schema "article_tags" do | ||
field(:title, :string) | ||
field(:color, :string) | ||
field(:thread, :string) | ||
field(:group, :string) | ||
belongs_to(:community, Community) | ||
belongs_to(:author, Author) | ||
timestamps(type: :utc_datetime) | ||
end | ||
def changeset(%ArticleTag{} = tag, attrs) do | ||
tag | ||
|> cast(attrs, @required_fields ++ @updatable_fields) | ||
|> validate_required(@required_fields) | ||
|> foreign_key_constraint(:user_id) | ||
|> foreign_key_constraint(:community_id) | ||
end | ||
def update_changeset(%ArticleTag{} = tag, attrs) do | ||
tag | ||
|> cast(attrs, @updatable_fields) | ||
|> foreign_key_constraint(:user_id) | ||
|> foreign_key_constraint(:community_id) | ||
end | ||
end |
11 changes: 9 additions & 2 deletionslib/groupher_server/cms/cms.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/abuse_report.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
43 changes: 1 addition & 42 deletionslib/groupher_server/cms/delegates/article_community.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
61 changes: 11 additions & 50 deletionslib/groupher_server/cms/delegates/article_curd.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.