-
Notifications
You must be signed in to change notification settings - Fork 9
[base + modules] Issue #670 - Remove side effects in manage_schema functions #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,8 @@ init(Context) -> | |
z_pivot_rsc:define_custom_pivot(ginger_search, [{is_unfindable, "boolean not null default false"}], Context). | ||
|
||
%% @doc When ACL is enabled, create a default user in the editors group | ||
manage_schema(_Version, Context) -> | ||
Datamodel = #datamodel{ | ||
manage_schema(_Version, _Context) -> | ||
#datamodel{ | ||
categories=[ | ||
{agenda, query, [ | ||
{title, {trans, [ | ||
|
@@ -168,9 +168,7 @@ manage_schema(_Version, Context) -> | |
]} | ||
]} | ||
] | ||
}, | ||
z_datamodel:manage(?MODULE, Datamodel, Context), | ||
schema:create_identity_if_not_exists(editor_dev, "redacteur", "redacteur", Context). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proposal to remove the automatic creation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've never used it, maybe @loetie has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is also an See https://test.zotonic.com/page/1353/modules manage_data(_Version, Context) ->
%% Whatever data needs to be installed after the datamodel
%% has been installed.
ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I completely agree, that struck me too. |
||
}. | ||
|
||
%% @doc Users without access to the admin should not be able to view unpublished | ||
%% resources | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
manage_schema/2 | ||
]). | ||
|
||
manage_schema(install, Context) -> | ||
Datamodel = #datamodel{ | ||
manage_schema(install, _Context) -> | ||
#datamodel{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Context -> _Context (unused) |
||
categories=[ | ||
{message, undefined, [ | ||
{is_unfindable, 1}, | ||
|
@@ -52,6 +52,4 @@ manage_schema(install, Context) -> | |
{message, category} | ||
]} | ||
] | ||
}, | ||
z_datamodel:manage(?MODULE, Datamodel, Context), | ||
ok. | ||
}. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,18 +34,8 @@ | |
-record(state, {context}). | ||
|
||
manage_schema(_, Context) -> | ||
Datamodel = #datamodel{ | ||
categories=[ | ||
{rdf, meta, [{title, <<"RDF resource">>}]} | ||
], | ||
resources=[ | ||
{rdf_content_group, content_group, [ | ||
{title, <<"RDF resources">>} | ||
]} | ||
] | ||
}, | ||
z_datamodel:manage(?MODULE, Datamodel, Context), | ||
|
||
%% TODO: Legacy code ahead! This function must not have side effects; | ||
%% it should only return the data model. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should look into this case to see if it is still necessary to keep this here, or if it could be in a better place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
%% Update some predicates so they can refer to category RDF, too | ||
case m_rsc:uri_lookup("http://xmlns.com/foaf/0.1/depiction", Context) of | ||
undefined -> noop; | ||
|
@@ -58,7 +48,17 @@ manage_schema(_, Context) -> | |
Context | ||
) | ||
end, | ||
ok. | ||
#datamodel{ | ||
categories=[ | ||
{rdf, meta, [ | ||
{title, <<"RDF resource">>} | ||
]} | ||
], | ||
resources=[ | ||
{rdf_content_group, content_group, [ | ||
{title, <<"RDF resources">>} | ||
]} | ||
]}. | ||
|
||
%% @doc Ask observers to provide subject links from the resource and object | ||
%% links to the resource | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It went nowhere, as I think it is not used / we should not use it (here) and rethink it when we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
manage_data/2
, it is called aftermanage_schema/2