Skip to content

Commit

Permalink
Merge branch 'po/nominated-info'
Browse files Browse the repository at this point in the history
* po/nominated-info:
  Add information about nominations to the CdC.
  Add links from photo to CdC page if elected.
  • Loading branch information
TurboGit committed Oct 28, 2013
2 parents e88ee5b + bf22ddf commit 728977f
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 7 deletions.
21 changes: 21 additions & 0 deletions web/src/v2p-callbacks-web_block.adb
Expand Up @@ -609,6 +609,27 @@ package body V2P.Callbacks.Web_Block is
(Template_Defs.Block_New_Vote.RATING, Ratings));
end New_Vote;

--------------------
-- Nominated_Data --
--------------------

procedure Nominated_Data
(Request : in Status.Data;
Context : not null access Services.Web_Block.Context.Object;
Translations : in out Templates.Translate_Set)
is
pragma Unreferenced (Request);
begin
if Context.Exist (Template_Defs.Set_Global.TID) then
Templates.Insert
(Translations,
Database.Vote.Get_Nominated_Data
(V2P.Context.Counter.Get_Value
(Context => Context.all,
Name => Template_Defs.Set_Global.TID)));
end if;
end Nominated_Data;

-----------------------
-- Photo_Of_The_Week --
-----------------------
Expand Down
5 changes: 5 additions & 0 deletions web/src/v2p-callbacks-web_block.ads
Expand Up @@ -37,6 +37,11 @@ package V2P.Callbacks.Web_Block is
Context : not null access Services.Web_Block.Context.Object;
Translations : in out Templates.Translate_Set);

procedure Nominated_Data
(Request : in Status.Data;
Context : not null access Services.Web_Block.Context.Object;
Translations : in out Templates.Translate_Set);

procedure CdC_Info
(Request : in Status.Data;
Context : not null access Services.Web_Block.Context.Object;
Expand Down
45 changes: 44 additions & 1 deletion web/src/v2p-database-vote.adb
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Vision2Pixels --
-- --
-- Copyright (C) 2010-2011 --
-- Copyright (C) 2010-2013 --
-- Pascal Obry - Olivier Ramonat --
-- --
-- This library is free software; you can redistribute it and/or modify --
Expand Down Expand Up @@ -38,6 +38,7 @@ with V2P.Template_Defs.Block_Cdc_Data;
with V2P.Template_Defs.Block_Cdc_Info;
with V2P.Template_Defs.Block_Global_Rating;
with V2P.Template_Defs.Block_New_Vote;
with V2P.Template_Defs.Block_Nominated_Data;
with V2P.Template_Defs.Block_Photo_Of_The_Week;
with V2P.Template_Defs.Block_User_Voted_Photos_List;
with V2P.Template_Defs.Chunk_List_Navlink;
Expand Down Expand Up @@ -283,6 +284,11 @@ package body V2P.Database.Vote is
Week_Id : constant String :=
DB.String_Vectors.Element (Line, 1);
begin
Templates.Insert
(Set,
Templates.Assoc
(Template_Defs.Block_Cdc_Data.CDC_ID,
DB.String_Vectors.Element (Line, 1)));
Templates.Insert
(Set,
Templates.Assoc
Expand Down Expand Up @@ -426,6 +432,43 @@ package body V2P.Database.Vote is
return Set;
end Get_Global_Rating;

------------------------
-- Get_Nominated_Data --
------------------------

function Get_Nominated_Data (Tid : in Id) return Templates.Translate_Set is
use type Templates.Tag;

DBH : constant TLS_DBH_Access := TLS_DBH_Access (DBH_TLS.Reference);
Set : Templates.Translate_Set;
Iter : DB.Iterator'Class := DB_Handle.Get_Iterator;
Line : DB.String_Vectors.Vector;
W_Id : Templates.Tag;
Date : Templates.Tag;
begin
Connect (DBH);

DBH.Handle.Prepare_Select
(Iter, "SELECT DISTINCT(week_id), elected_on"
& " FROM photo_of_the_week p, user_photo_of_the_week u"
& " WHERE u.post_id=" & To_String (Tid)
& " AND week_id!=0 AND week_id=p.id"
& " ORDER BY week_id DESC");

while Iter.More loop
Iter.Get_Line (Line);
W_Id := W_Id & DB.String_Vectors.Element (Line, 1);
Date := Date & DB.String_Vectors.Element (Line, 2);
end loop;

Templates.Insert
(Set, Templates.Assoc (Block_Nominated_Data.WEEK_ID, W_Id));
Templates.Insert
(Set, Templates.Assoc (Block_Nominated_Data.DATE, Date));

return Set;
end Get_Nominated_Data;

---------------------------
-- Get_Photo_Of_The_Week --
---------------------------
Expand Down
5 changes: 4 additions & 1 deletion web/src/v2p-database-vote.ads
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Vision2Pixels --
-- --
-- Copyright (C) 2010-2011 --
-- Copyright (C) 2010-2013 --
-- Pascal Obry - Olivier Ramonat --
-- --
-- This library is free software; you can redistribute it and/or modify --
Expand Down Expand Up @@ -46,6 +46,9 @@ package V2P.Database.Vote is
function Get_CdC_Data (Tid : in Id) return Templates.Translate_Set;
-- Returns all data about a specific CdC (score, voting users)

function Get_Nominated_Data (Tid : in Id) return Templates.Translate_Set;
-- Returns nominated data for the given Tid

function Get_CdC_Info return Templates.Translate_Set;
-- Returns the current CdC information

Expand Down
10 changes: 8 additions & 2 deletions web/src/v2p-database.adb
Expand Up @@ -1391,7 +1391,9 @@ package body V2P.Database is
& Utils.Image (Settings.Anonymity_Hours)
& " hour') - JULIANDAY('NOW')) * 24, category.name, category.id, "
& "(SELECT id FROM photo_of_the_week AS cdc "
& " WHERE cdc.post_id=post.id), DATE('now')>disabled_since "
& " WHERE cdc.post_id=post.id), DATE('now')>disabled_since, "
& "(SELECT COUNT(*) FROM user_photo_of_the_week q "
& " WHERE q.post_id=post.id AND week_id!=0) "
& "FROM post, user, user_post, photo, category "
& "WHERE post.id=" & To_String (Tid)
& " AND user.login=user_post.user_login"
Expand Down Expand Up @@ -1522,8 +1524,12 @@ package body V2P.Database is
Templates.Insert
(Set, Templates.Assoc
(Page_Forum_Entry.CDC,
DB.String_Vectors.Element (Line, 16) /= ""));
DB.String_Vectors.Element (Line, 16)));

Templates.Insert
(Set, Templates.Assoc
(Page_Forum_Entry.NOMINATED,
DB.String_Vectors.Element (Line, 18)));
Line.Clear;
end if;

Expand Down
2 changes: 1 addition & 1 deletion web/templates/block_cdc_data.thtml
@@ -1,7 +1,7 @@
@@INCLUDE@@ set_babel.thtml
@@--
<div id="bcd_data">
<p>@_BABEL_ON_DATE_@ <span id="bcd_info">@_DATE_@</span>
<p>@_BABEL_ON_DATE_@ <span id="bcd_info"><a href="/votes/@_CDC_ID_@">@_DATE_@</a></span>
- score <span id="bcd_info">@_SCORE_@</span> - @_BABEL_BY_@ :</p>
@@TABLE@@
<span id="bcd_user_name"><a href="/~@_URL_ENCODE:USERS_@">@_USERS_@</a></span>
Expand Down
10 changes: 10 additions & 0 deletions web/templates/block_nominated_data.thtml
@@ -0,0 +1,10 @@
@@INCLUDE@@ set_babel.thtml
@@--
<div id="bnom_data">
@_BABEL_NOMINATED_ON_@
@@INLINE@@
@@TABLE@@
<span id="bnom_info"><a href="/votes/@_WEEK_ID_@">@_DATE_@</a></span>
@@END_TABLE@@
@@END_INLINE@@
</div>
7 changes: 5 additions & 2 deletions web/templates/page_forum_entry.thtml
Expand Up @@ -114,8 +114,8 @@
<div id="pfe_lazy_global_rating">@_LAZY_GLOBAL_RATING_@</div>
</div>
@@-- Vote photo of the week (only for photo forum)
@@IF@@ @_CDC_@
<div id="pfe_cdc"><a href="/cdc" id="pfe_cdclink" title="@_BABEL_YOUR_CDC_@">&hearts;</a>&nbsp;
@@IF@@ @_CDC_@ /= ""
<div id="pfe_cdc"><a href="/votes/@_CDC_@" id="pfe_cdclink" title="@_BABEL_YOUR_CDC_@">&hearts;</a>&nbsp;
<a href="#cdcdata" id="pfe_toggle_cdcdata" class="link"
rel="pfe_cdcdata_table">@_BABEL_HAS_BEEN_CDC_@&nbsp;<span id="pfe_symbol">@_BABEL_SYM_CLOSED_@</span></a>
@@INCLUDE@@ ../we_js/chunk_show_hide.tjs pfe pfe_cdcdata_table pfe_symbol
Expand All @@ -127,6 +127,9 @@
@@ELSE@@
<div id="pfe_lazy_vote_week_photo">@_LAZY_VOTE_WEEK_PHOTO_@</div>
@@END_IF@@
@@IF@@ @_NOMINATED_@ > 0
@_LAZY_NOMINATED_DATA_@
@@END_IF@@
@@END_IF@@

@@-- Comments
Expand Down
1 change: 1 addition & 0 deletions web/templates/set_babel.thtml
Expand Up @@ -257,3 +257,4 @@
@@SET@@ BABEL_VOTES_PER_USER="Votes par utilisateur"
@@SET@@ BABEL_DISABLE_USER="Activer/Désactiver mon compte"
@@SET@@ BABEL_USER_DISABLED="Utilisateur désactivé"
@@SET@@ BABEL_NOMINATED_ON="Nomination(s) au CdC :"

0 comments on commit 728977f

Please sign in to comment.