<field name="created" reporter:datatype="timestamptz"/>
<field name="image" reporter:datatype="text"/>
<field name="systems" oils_persist:virtual="true" reporter:datatype="link" />
+ <field name="rating" oils_persist:virtual="true" reporter:datatype="link" />
+ <field name="rating_entries" oils_persist:virtual="true" reporter:datatype="link" />
</fields>
<links>
<link field="author" reltype="has_a" key="id" map="" class="au"/>
<link field="source" reltype="has_a" key="id" map="" class="dss"/>
- <link field="systems" reltype="has_many" key="" map="compat_system" class="dpcm"/>
+ <link field="systems" reltype="has_many" key="package" map="compat_system" class="dpcm"/>
+ <link field="rating_entries" reltype="has_many" key="package" map="" class="dr"/>
+ <link field="rating" reltype="a" key="package" map="" class="ddr"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
</permacrud>
</class>
+ <class id="ddr" controller="sharestuff.cstore sharestuff.pcrud" oils_obj:fieldmapper="depository::derived_rating" oils_persist:tablename="depository.derived_rating" oils_persist:field_safe="true" reporter:label="Average Package Rating">
+ <fields oils_persist:primary="package">
+ <field name="package" reporter:datatype="link"/>
+ <field name="rating" reporter:datatype="float"/>
+ </fields>
+ <links>
+ <link field="package" reltype="has_a" key="id" map="" class="dp"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="RATE" global_required="true"/>
+ <retrieve/>
+ <delete permission="KILLRATE" global_required="true"/>
+ </actions>
+ </permacrud>
+ </class>
+
<class id="dif" controller="sharestuff.cstore sharestuff.pcrud" oils_obj:fieldmapper="depository::item_field" oils_persist:tablename="depository.item_field" oils_persist:field_safe="true" reporter:label="Item Field">
<fields oils_persist:primary="id" oils_persist:sequence="depository.item_field_id_seq">
IF pkg_id
INCLUDE package_details
- pkg = cstore.retrieve_depository_package( [ cgi.param( 'pkg' ), { flesh => 1, flesh_fields => { dp => ['systems'] } } ] )
+ pkg = cstore.retrieve_depository_package( [ cgi.param( 'pkg' ), { flesh => 1, flesh_fields => { dp => ['systems','rating'] } } ] )
systems = cstore.retrieve_all_depository_source_system();
ELSE
'[' IF api;
- FOREACH p IN cstore.search_depository_package( [ { author => user.id() }, { flesh => 1, flesh_fields => { dp => ['systems'] } } ] );
+ FOREACH p IN cstore.search_depository_package( [ { author => user.id() }, { flesh => 1, flesh_fields => { dp => ['systems','rating'] } } ] );
INCLUDE package_summary pkg = p;
IF api
',';
public => pkg.public(),
image => pkg.image(),
description => pkg.description(),
+ rating => pkg.rating(),
systems => sysnames
};
p.json;
<table style="border-collapse:collaps; border-width:1px">
<tr>
<th>Title</th>
- <td><input name="title" type="text" value="[% pkg.title() | html %]"/></td>
+ <td><input name="title" type="text" value="[% pkg.title() | html %]"/> (Rating: [% pkg.rating() | html %])</td>
</tr>
<tr>
<th>Description</th>
p = { title => pkg.title(),
pkg_version => pkg.pkg_version(),
created => pkg.created(),
+ rating => pkg.rating(),
description => pkg.description(),
systems => sysnames
};
<tr>
<th>Title</th>
<td><a href="?pkg=[% pkg.id() %]">[% pkg.title() | html %]</a></td>
+ <th>Rating</th>
+ <td>[% pkg.rating() | html %]</td>
<th>Version</th>
<td>[% pkg.pkg_version() | html %]</td>
<th>Created</th>
</tr>
<tr>
<th>Description</th>
- <td colspan="5">[% pkg.description() | html %]</textarea></td>
+ <td colspan="7">[% pkg.description() | html %]</textarea></td>
<td>
[% FOREACH s IN sysnames.sort %]
[% s.name() | html %]<br/>