Commits

Andreas Stenius committed 5b13309

Adding templates for editing zmr resources in the admin interface. Begun work on a zmr model.

  • Participants
  • Parent commits 2a7118f

Comments (0)

Files changed (4)

 
 -module(mod_zmr).
 -author("Andreas Stenius <andreas.stenius@astekk.se>").
+%-behaviour(gen_server).
 
 -mod_title("ZMR Server").
 -mod_description("A Zotonic module repository server.").
 %% interface functions
 -export([
 	 init/1
+%	 handle_call/3,
+%	 handle_cast/2,
+%	 handle_info/2,
+%	 terminate/2,
+%	 code_change/3,
+%	 start_link/1
 	]).
 
--include("zotonic.hrl").
+-include_lib("zotonic.hrl").
+%-record(state, {context}).
 
+%start_link(Args) when is_list(Args) ->
+%    gen_server:start_link(?MODULE, Args, []).
 
+%init(Args) ->
 init(Context) ->
+%    process_flag(trap_exit, true),
+%    {context, Context} = proplists:lookup(context, Args),
     z_datamodel:manage(?MODULE, datamodel(), Context),
+%    {ok, #state{context = z_context:new(Context)}}.
     ok.
 
 datamodel() ->
       [
        {zmr_scm,
 	[{title, <<"Source Code Management">>}],
-	[{zmr_repository, zmr_scm_tool}]}
+	[{zmr_repository, zmr_scm_tool}]},
+       
+       %% perhaps use the existing 'relation' predicate for this instead... ?
+       {zmr_module_release,
+	[{title, <<"Release for">>}],
+	[{zmr_release, zmr_repository}]}
       ]
      },
 
 	 {summary, <<"The repository for ZMR itself.">>},
 	 {body, <<"Zotonic Modules Repository (zmr) is a server for hosting releases of zotonic modules.">>},
 	 {zmr_repository_path, <<"https://bitbucket.astekk.se/zmr">>}
+	]},
+
+       {zmr_default_release,
+	zmr_release,
+	[
+	 {title, <<"Default ZMR release (head)">>},
+	 {zmr_branch, <<"default">>}
 	]}
       ]},
 
      {edges,
       [
-       {zmr_repo, zmr_scm, zmr_scm_hg}
+       {zmr_repo, zmr_scm, zmr_scm_hg},
+       {zmr_default_release, zmr_module_release, zmr_repo},
+
+       %% using the existing 'relation' predicate
+       {zmr_repo, relation, zmr_default_release},
+       {zmr_default_release, relation, zmr_repo}
       ]}
 
     ].

File models/m_zmr.erl

+%%% @author Andreas Stenius <andreas.stenius@astekk.se>
+%%% @copyright (C) 2011, Andreas Stenius
+%%% @doc
+%%%
+%%% @end
+%%% Created :  3 Feb 2011 by Andreas Stenius <andreas.stenius@astekk.se>
+
+
+-module(m_zmr).
+-author("Andreas Stenius <andreas.stenius@astekk.se>").
+
+-behaviour(gen_model).
+
+-export([
+	 m_find_value/3,
+	 m_to_list/2,
+	 m_value/2
+	]).
+
+-include_lib("zotonic.hrl").
+
+m_find_value(repo, #m{value=undefined} = M, _Context) ->
+    M#m{value=repo};
+m_find_value(Id, #m{value=repo} = M, Context) ->
+    case m_rsc:rid(Id, Context) of
+	undefined ->
+	    undefined;
+	RId ->
+	    case z_acl:rsc_visible(RId, Context) of
+		true ->
+		    M#m{value={repo, RId}};
+		false ->
+		    fun(is_a, C) ->
+			    m_rsc:is_a(RId, C);
+		       (_, _C) ->
+			    undefined
+		    end
+	    end
+    end.
+
+%m_find_value(_, _, _) -> undefined.
+
+m_to_list(_, _) ->
+    undefined.
+
+m_value(_, _) ->
+    undefined.
+
+
+
+

File templates/_admin_edit_content.zmr_release.tpl

+
+{% with m.rsc[id] as r %}
+<div class="item-wrapper">
+<h3 class="above-item clearfix">
+<span class="title">{_ ZMR Release _}</span>
+</h3>
+
+<div class="item">
+<fieldset class="admin-form">
+
+<div class="form-item clearfix">
+<label for="zmr_branch">{_ Branch/Revision/Changeset _}</label>
+<input id="zmr_branch" type="text" name="zmr_branch" value="{{ r.zmr_branch }}" style="width: 80%" />
+<br />
+{% button text=_"Show log" action={dialog_open title="Select branch from log" template="_zmr_select_branch.tpl" target="zmr_branch"} %}
+</div>
+
+
+</fieldset>
+</div>
+
+</div>
+{% endwith %}

File templates/_zmr_select_branch.tpl

+select branch, target: {{ target }}
+
+{% print m.zmr.repo.zmr_repository %}