Le repo des sources pour le site web des JM2L
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

336 lines
14 KiB

  1. <%inherit file="jm2l:templates/layout.mako"/>
  2. <%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
  3. <%def name="cssAddOn()">
  4. <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" />
  5. <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
  6. <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui.css">
  7. <!-- CSS adjustments for browsers with JavaScript disabled -->
  8. <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-noscript.css"></noscript>
  9. <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript>
  10. </%def>
  11. <div class="row-fluid">
  12. <div class="span10 offset1">
  13. <a class="pull-right" href="/categorie/entity">Editer les catégories</a>
  14. <br>
  15. <form action="" method="POST">
  16. % if 'uid' in form._fields:
  17. ${form.uid}
  18. %endif
  19. <%
  20. DicForm = {
  21. 'name': {'PlaceHolder':u"Nom", 'ContainerStyle':"padding-right:5px;float:left;width:35em;", "FieldStyle":"width:31em;"},
  22. 'tiers_type': {'PlaceHolder':u"Nature", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:15em;"},
  23. 'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;padding-top: 20px;", "FieldStyle":"width:90%;min-height:150px;" },
  24. 'website': {'PlaceHolder':u"Site web", 'ContainerStyle':"padding-right:15px;padding-top: 20px;", 'FieldStyle':"width:30em;"},
  25. 'membership': {'Ignore':True },
  26. 'roles': {'Ignore':True }
  27. }
  28. %>
  29. ${helpers.DisplayForm(form, DicForm)}
  30. % if 'uid' in form._fields:
  31. <fieldset>
  32. <legend>Ses acteurs</legend>
  33. <div class="repeat">
  34. <table class="wrapper table" width="100%">
  35. <thead>
  36. <tr class="row">
  37. <th style="width:5em;text-align:center;">Année</th>
  38. <th style="width:22em;text-align:center;">Personne</th>
  39. <th style="width:22em;text-align:center;">Rôle</th>
  40. <th style="width:10em;text-align:center;">Action</th>
  41. </tr>
  42. </thead>
  43. <tbody class="container" id="tab_member">
  44. <tr class="row template" style="line-height:2.2em;">
  45. <td>
  46. <select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid"
  47. id="membership-{{row-count-placeholder}}-year_uid">
  48. % for year in range(2015, 2005, -1):
  49. <%
  50. if year in [2014]:
  51. continue
  52. %> \
  53. <option value="${year}">${year}</option>
  54. %endfor
  55. </select>
  56. </td>
  57. <td style="text-align: center;">
  58. <input type="hidden" style="width:20em;" class="form-control" name="membership-{{row-count-placeholder}}-user_uid"
  59. id="membership-{{row-count-placeholder}}-user_uid" />
  60. </td>
  61. <td style="text-align: center;">
  62. <input type="text" class="form-control" name="membership-{{row-count-placeholder}}-role" />
  63. </td>
  64. <td>
  65. <span class="remove btn btn-mini btn-danger">
  66. <i class="icon-remove-sign icon-white"></i> Suppr.
  67. </span>
  68. </td>
  69. </tr>
  70. % for num, dicdata in enumerate(form._fields.get("membership").data):
  71. <tr class="row" style="padding:5px;line-height:2.2em;">
  72. <td style="text-align:center;">
  73. <input type="hidden" class="form-control" name="membership-${num}-year_uid"
  74. id="membership-${num}-year_uid"
  75. value="${dicdata.get('year_uid')}" style="width:4em;" />
  76. <div id="content-member-${num}-year_uid">${dicdata.get('year_uid')}</div>
  77. </td>
  78. <td style="text-align:center;">
  79. <input type="hidden" class="form-control" name="membership-${num}-user_uid"
  80. id="membership-${num}-user_uid" value="${dicdata.get('user_uid')}" style="width:4em;" />
  81. <%
  82. tmpUser = DBUser.by_id(dicdata.get('user_uid'))
  83. %>
  84. % if tmpUser:
  85. <div id="content-member-${num}-user_uid">${tmpUser.prenom} ${tmpUser.nom}</div>
  86. % endif
  87. </td>
  88. <td style="text-align:center;">
  89. <input type="text" class="form-control" name="membership-${num}-role" style="display:none;width:95%;"
  90. id="membership-${num}-role"
  91. value="${dicdata.get('role', 'Aucun')}" />
  92. <div id="content-member-${num}-role"><i>${dicdata.get('role', 'Aucun')}</i></div>
  93. </td>
  94. <td>
  95. <a class="btn btn-mini btn-primary" href="#" onclick="return edit_member(this, ${num});">
  96. <i class="icon-pencil icon-white"></i> Edit.
  97. </a>
  98. <span class="remove btn btn-mini btn-danger">
  99. <i class="icon-remove-sign icon-white"></i> Suppr.
  100. </span>
  101. </td>
  102. </tr>
  103. % endfor
  104. </tbody>
  105. <tfoot>
  106. <tr>
  107. <td colspan="5" style="text-align:center;line-height: 3em;">
  108. <span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Ajouter</span>
  109. </td>
  110. </tr>
  111. </tfoot>
  112. </table>
  113. </div>
  114. </fieldset>
  115. % endif
  116. % if 'uid' in form._fields:
  117. <fieldset>
  118. <legend>Ses rôles</legend>
  119. <div class="repeat">
  120. <table class="wrapper table" width="100%">
  121. <thead>
  122. <tr class="row">
  123. <th style="width:5em;text-align:center;">Année</th>
  124. <th style="width:22em;text-align:center;">Rôle</th>
  125. <th style="width:10em;text-align:center;">Action</th>
  126. </tr>
  127. </thead>
  128. <tbody class="container" id="tab_role">
  129. <tr class="row template" style="line-height:2.2em;">
  130. <td>
  131. <select class="form-control" style="width:5em;" name="roles-{{row-count-placeholder}}-year_uid"
  132. id="roles-{{row-count-placeholder}}-year_uid">
  133. % for year in range(2015, 2005, -1):
  134. <%
  135. if year in [2014]:
  136. continue
  137. %> \
  138. <option value="${year}">${year}</option>
  139. %endfor
  140. </select>
  141. </td>
  142. <td style="text-align: center;">
  143. <select class="form-control" name="roles-{{row-count-placeholder}}-tiers_role" />
  144. <option value="Exposant">Exposant</option>
  145. <option value="Sponsor">Sponsor</option>
  146. <option value="Donateur">Donateur</option>
  147. </select>
  148. </td>
  149. <td>
  150. <span class="remove btn btn-mini btn-danger">
  151. <i class="icon-remove-sign icon-white"></i> Suppr.
  152. </span>
  153. </td>
  154. </tr>
  155. % for num, dicdata in enumerate(form._fields.get("roles").data):
  156. <tr class="row" style="padding:5px;line-height:2.2em;">
  157. <td style="text-align:center;">
  158. <input type="hidden" class="form-control" name="roles-${num}-year_uid"
  159. id="roles-${num}-year_uid"
  160. value="${dicdata.get('year_uid')}" style="width:4em;" />
  161. <div id="content-role-${num}-year_uid">${dicdata.get('year_uid')}</div>
  162. </td>
  163. <td style="text-align:center;">
  164. <input type="hidden" class="form-control" name="roles-${num}-tiers_role"
  165. id="roles-${num}-tiers_role"
  166. value="${dicdata.get('tiers_role', 'Aucun')}" />
  167. <div id="content-role-${num}-tiers_role"><i>${dicdata.get('tiers_role', 'Aucun')}</i></div>
  168. </td>
  169. <td>
  170. <a class="btn btn-mini btn-primary" href="#" onclick="return edit_role(this, ${num});">
  171. <i class="icon-pencil icon-white"></i> Edit.
  172. </a>
  173. <span class="remove btn btn-mini btn-danger">
  174. <i class="icon-remove-sign icon-white"></i> Suppr.
  175. </span>
  176. </td>
  177. </tr>
  178. % endfor
  179. </tbody>
  180. <tfoot>
  181. <tr>
  182. <td colspan="5" style="text-align:center;line-height: 3em;">
  183. <span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Ajouter</span>
  184. </td>
  185. </tr>
  186. </tfoot>
  187. </table>
  188. </div>
  189. </fieldset>
  190. % endif
  191. % if 'uid' in form._fields:
  192. <button class="btn btn-primary" type="submit">Enregistrer</button>
  193. % else:
  194. <button class="btn btn-primary" type="submit">Proposer</button>
  195. % endif
  196. </form>
  197. % if 'uid' in form._fields:
  198. % if request.user:
  199. <fieldset>
  200. <legend>Les supports liés</legend>
  201. <div style="float:right;width:60%">
  202. <p> En plus de vos support de présentation classique.
  203. Pensez aussi aux affiches, aux flyers, aux stickers,
  204. au bulletin d'adhésion à une association, à la documentation technique...
  205. Tous ce qui peut être utile, de près ou de loin à sa promotion.
  206. </p>
  207. </div>
  208. ${helpers.uploader("tiers", form.uid.data, u"fichiers" )}
  209. </fieldset>
  210. % else:
  211. <br>NB: Vous devez être identifié afin de proposer du contenu.
  212. % endif
  213. % else:
  214. <br>NB: Vous devez proposer votre entité avant de pouvoir
  215. téléverser des fichiers la concernant.
  216. % endif
  217. </div>
  218. </div>
  219. <%def name="jsAddOn()">
  220. <script src="/vendor/select2/js/select2.js"></script>
  221. <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script>
  222. <script src="/vendor/ckeditor/ckeditor.js"></script>
  223. <script type="text/javascript">
  224. var year_data = Array();
  225. var role_data = Array();
  226. var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } );
  227. for (var i=2005;i<2016;i++)
  228. year_data.push( {id:i, text:i.toString()});
  229. role_data.push({id:'Exposant', text:'Exposant'});
  230. role_data.push({id:'Sponsor', text:'Sponsor'});
  231. role_data.push({id:'Donateur', text:'Donateur'});
  232. $("#tiers_type").select2({});
  233. function show_editor() {
  234. if (editor) {
  235. editor.destroy();
  236. editor=null;
  237. } else
  238. editor = CKEDITOR.replace('description');
  239. }
  240. jQuery(function() {
  241. jQuery('.repeat').each(function() {
  242. jQuery(this).repeatable_fields(
  243. {
  244. is_ready: function(container, therow) {
  245. var numrow=$(container).attr('data-rf-row-count');
  246. if ($(container).attr("id")=="tab_member") {
  247. $("#membership-"+ (numrow-1) +"-user_uid").select2(
  248. {
  249. placeholder: 'Entrez ici un Nom ou un Prénom',
  250. minimumInputLength: 2, allowClear: true,
  251. ajax: {
  252. quietMillis: 250, url: "/json-users", dataType: 'json',
  253. data: function (term, page) {
  254. return { pageSize: 8, pageNum: page, searchTerm: term };
  255. },
  256. results: function (data, page) {
  257. var more = (page * 8) < data.Total;
  258. return { results: data.Results, more: more };
  259. }
  260. }
  261. });
  262. $("#membership-"+ (numrow-1) +"-year_uid").select2({});
  263. }
  264. if ($(container).attr("id")=="tab_role") {
  265. $("#roles-"+ (numrow-1) +"-year_uid").select2({});
  266. $("#roles-"+ (numrow-1) +"-tiers_role").select2({});
  267. }
  268. }
  269. });
  270. });
  271. });
  272. function edit_member(srcobj, num) {
  273. $(srcobj).addClass("disabled");
  274. $("#content-member-"+ num +"-year_uid").hide();
  275. $("#membership-"+ num +"-year_uid").select2({
  276. width:'80px',
  277. data: year_data
  278. });
  279. //$('select').select2();
  280. $("#content-member-"+ num +"-user_uid").hide();
  281. $("#membership-"+ num +"-user_uid").select2(
  282. {
  283. width:'250px',
  284. placeholder: 'Entrez ici un Nom ou un Prénom',
  285. minimumInputLength: 2, allowClear: true,
  286. initSelection: function(element, callback){
  287. callback({id: element.val(), text: $("#content-member-"+ num +"-user_uid").text() })
  288. },
  289. ajax: {
  290. quietMillis: 250, url: "/json-users", dataType: 'json',
  291. data: function (term, page) {
  292. return { pageSize: 8, pageNum: page, searchTerm: term };
  293. },
  294. results: function (data, page) {
  295. var more = (page * 8) < data.Total;
  296. return { results: data.Results, more: more };
  297. }
  298. }
  299. });
  300. $("#content-member-"+ num +"-role").hide();
  301. $("#membership-"+ num +"-role").show();
  302. return false;
  303. };
  304. function edit_role(srcobj, num) {
  305. $(srcobj).addClass("disabled");
  306. $("#roles-"+ num +"-year_uid").select2({
  307. width:'80px',
  308. data: year_data
  309. });
  310. $("#roles-"+ num +"-tiers_role").select2({
  311. width:'100%',
  312. data: role_data
  313. });
  314. $("#content-role-"+ num +"-year_uid").hide();
  315. $("#content-role-"+ num +"-tiers_role").hide();
  316. $("#roles-"+ num +"-tiers_role").show();
  317. return false;
  318. };
  319. </script>
  320. </%def>