Remove old materials from categories
[cds-indico.git] / indico / MaKaC / webinterface / tpls / CategoryDisplay.tpl
blob559ae1b9dcb05e53a521c2ed56d72ea0da4a7450
1 <%
2 urlConference = urlHandlers.UHConferenceCreation.getURL(categ)
3 urlConference.addParam("event_type","conference")
5 urlLecture = urlHandlers.UHConferenceCreation.getURL(categ)
6 urlLecture.addParam("event_type", "lecture")
8 urlMeeting = urlHandlers.UHConferenceCreation.getURL(categ)
9 urlMeeting.addParam("event_type","meeting")
11 containsCategories = len(categ.getSubCategoryList()) > 0
12 from MaKaC.conference import Link
13 from MaKaC.webinterface.general import strfFileSize
16 <%def name="render_attachments(attachments)">
17     % for attachment in attachments:
18         <li class="icon-file">
19             % if attachment.type.name == 'link':
20             <a href="${attachment.download_url}" target="_blank" class="resource"
21                data-name="${attachment.title}">
22                 ${attachment.title}
23             </a>
24             % else:
25             <a href="${attachment.download_url}" target="_blank" class="resource"
26                data-name="${attachment.file.filename}"
27                data-size="${attachment.file.size}"
28                data-date="${attachment.modified_dt}">
29                 ${attachment.title}
30             </a>
31             % endif
32             % if attachment.is_protected:
33                 <i class="icon-lock"></i>
34             % endif
35         </li>
36     % endfor
37 </%def>
39 <div class="category-container">
40     <div class="category-header">
41         <div id="category-toolbar" class="toolbar right">
42             <div class="group">
43                 % if not isRootCategory:
44                 <a class="i-button icon-arrow-up" href="${urlHandlers.UHCategoryDisplay.getURL(categ.owner)}">
45                     Parent category
46                 </a>
47                 % endif
48                 % if categ.conferences:
49                     <a id="exportIcal${categ.getUniqueId()}" class="i-button icon-calendar arrow exportIcal" data-id="${categ.getUniqueId()}" title="${_("Export to scheduling tool")}"></a>
50                     <span><%include file="CategoryICalExport.tpl" args="item=categ"/></span>
51                 % endif
52                 <a id="moreLink" class="i-button icon-eye arrow" data-toggle="dropdown" title="${_("View")}"></a>
53                 <ul class="dropdown">
54                     <li><a href="${urlHandlers.UHCategoryOverview.getURL(categ)}">${_("Today's events")}</a></li>
55                     <li><a href="${urlHandlers.UHCategoryOverview.getWeekOverviewUrl(categ)}">${_("Week's events")}</a></li>
56                     <li><a href="${urlHandlers.UHCalendar.getURL([categ])}">${_("Calendar")}</a></li>
57                     <li><a href="${urlHandlers.UHCategoryMap.getURL(categ)}">${_("Category map")}</a></li>
58                     <li><a href="${urlHandlers.UHCategoryStatistics.getURL(categ)}">${_("Category statistics")}</a></li>
59                 </ul>
60                 <a id="createEventLink" class="i-button icon-plus arrow" data-toggle="dropdown" title="${_("Create new event")}"></a>
61                 <ul class="dropdown">
62                     <li><a href="${urlLecture}">${_("Lecture")}</a></li>
63                     <li><a href="${urlMeeting}">${_("Meeting")}</a></li>
64                     <li><a href="${urlConference}">${_("Conference")}</a></li>
65                 </ul>
66                 % if allowUserModif:
67                 <a id="manageLink" class="i-button icon-edit arrow" data-toggle="dropdown" title="${_("Management options")}"></a>
68                 <ul class="dropdown">
69                     <li><a href="${urlHandlers.UHCategoryModification.getURL(categ)}">${_("Edit category")}</a></li>
70                     <li><a href="${urlHandlers.UHCategoryCreation.getURL(categ)}">${_("Add subcategory")}</a></li>
71                 </ul>
72                 % endif
73             </div>
74             % if isLoggedIn and not isRootCategory:
75             <div id="categFavorite" class="group">
76                 <button type="button"
77                         class="i-button fav-button icon-only icon-bookmark ${'enabled' if categ in _session.user.favorite_categories else ''}"
78                         data-href="${ url_for('users.user_favorites_category_api', category_id=categ.id) }"></button>
79             </div>
80             % endif
81         </div>
83         <h1 class="category-title ${"sidebar-padding" if isRootCategory or categ.attached_items or managers or allowUserModif else ""}">
84         % if isRootCategory and containsCategories:
85             ${ _("Main categories") }
86         % elif isRootCategory:
87             ${ _("All events") }
88         % else:
89             ${ name | remove_tags }
90         % endif
91         </h1>
92     </div>
94     % if isRootCategory or categ.attached_items or managers or allowUserModif:
95     <div class="category-sidebar">
96         % if isRootCategory:
97             % if isNewsActive:
98                 <h2 class="icon-bullhorn">
99                     ${_("News")}
100                     <a href="${ urlHandlers.UHIndicoNews.getURL()}" class="more-icon">${ _("more...") }</a>
101                 </h2>
102                 <%include file="WelcomeHeader.tpl" args="tz = timezone"/>
103             % endif
104             % if upcomingEvents:
105                 <h2 class="icon-alarm">${_("Upcoming events")}</h2>
106                     ${upcomingEvents}
107             % endif
108         % else:
109             % if managers:
110                 <h2 class="icon-medal">${ _("Managers") }</h2>
111                 <ul id="manager-list">
112                 % for type, mgr_name in managers:
113                     <li class="${type}">${mgr_name}</li>
114                 % endfor
115                 </ul>
116             % endif
117             % if categ.attached_items or allowUserModif:
118                 <div>
119                     % if allowUserModif:
120                         <div class="right">
121                             <a href="#" id="manageMaterial" class="i-button icon-edit"></a>
122                         </div>
123                     % endif
124                     <h2 class="icon-package-download">${ _("Files") }</h2>
125                 </div>
126                 <ul class="resource-list">
127                     ${render_attachments(categ.attached_items.get('files', []))}
128                 </ul>
129                 <ul>
130                 % for folder in categ.attached_items.get('folders', []):
131                     <li>
132                         <a class="material-show" data-hidden="true" title="${folder.title}">
133                            <div class="left material-title-icon icon-next" ></div>
134                            <h3>${folder.title}</h3>
135                            % if folder.is_protected:
136                                <i class="icon-lock"></i>
137                            % endif
138                         </a>
139                         <ul class="resource-list" style="display: none">
140                             ${render_attachments(folder.attachments)}
141                         </ul>
142                      </li>
143                 % endfor
144                 </ul>
145             % endif
146         % endif
147     </div>
148     % endif
151     <div class="category-content-wrapper">
152         <div class="category-content">
153             ${ render_template('flashed_messages.html') }
154             <div class="category-info">
156             % if isRootCategory:
157                 ${_("Welcome to Indico. The Indico tool allows you to manage complex conferences, workshops and meetings.<br/> In order to start browsing, please select one of the categories below.")}
158             % elif description:
159                 ${description}
160             % endif
161             </div>
163             <div>
164                 ${ contents }
165             </div>
166         </div>
167     </div>
169 </div>
171 <script>
172 $(document).ready(function(){
174     $("#category-toolbar").dropdown();
176     var PROTECTION_TEXT = {
177             'domain': $T("This category is protected by domain: "),
178             'restricted': $T("This category is restricted to some users")
179         };
181     // Make category entries fully clickable (wrap in <a>)
182     $('.category-list li').each(function() {
183          return $(this).children().wrapAll(
184              $('<a class="invisible-block"/>').attr('href', $(this).find('a').attr('href'))
185          );
186     });
188     $('.protection').qtip({
189         content: {
190             text: function() {
191                 var type = $(this).data('type');
192                 var domains = ($(this).data('domain') || []).join(", ");
193                 return PROTECTION_TEXT[type] + (type == "domain" ? domains : "");
194             }
195         },
196         position: {
197             my: 'top center',
198             at: 'bottom center'
199         }
200     })
202     $('a.resource').qtip({
203         content: {
204             text: function() {
205                 var content = $("<div/>");
206                 var list = $("<ul/>").addClass("category-resource-qtip");
207                 $("<li/>").append($("<span/>").addClass("bold").append("{0}: ".format($T("Name")))).append($(this).data("name")).appendTo(list);
208                 if($(this).data("size") !== undefined) {
209                     $("<li/>").append($("<span/>").addClass("bold").append("{0}: ".format($T("File size")))).append($(this).data("size")).appendTo(list);
210                 }
211                 if($(this).data("date") !== undefined) {
212                     $("<li/>").append($("<span/>").addClass("bold").append("{0}: ".format($T("File creation date")))).append($(this).data("date")).appendTo(list);
213                 }
214                 list.appendTo(content);
215                 return content;
216             }
217         }
218     });
220     $('.material-show').click(function() {
221         var $this = $(this),
222             transition_opts = {
223                 duration: 250,
224                 easing: 'easeInQuad'
225             };
227         if ($this.data('hidden')) {
228             $this.siblings('.resource-list').slideDown(transition_opts);
229             $this.data('hidden', false);
230             $this.children(".material-title-icon").removeClass('icon-next').addClass('icon-expand');
231         } else {
232             $this.siblings('.resource-list').slideUp(transition_opts);
233             $this.data('hidden', true);
234             $this.children(".material-title-icon").removeClass('icon-expand').addClass('icon-next');
235         }
236     });
238 </script>
240 % if isLoggedIn:
241     <script type="text/javascript">
242         $(document).ready(function(){
243             $("#manageMaterial").click(function(){
244                 openAttachmentManager(${categ.getLocator() | n,j});
245             });
247             $('.toolbar .i-button').qtip({
248                 position: {
249                     my: 'bottom center',
250                     at: 'top center'
251                 }
252             });
254             $('.i-button.fav-button').on('click', function() {
255                 var $this = $(this);
256                 var isFavorite = $this.hasClass('enabled');
257                 $this.prop('disabled', true);
258                 $.ajax({
259                     url: $this.data('href'),
260                     method: isFavorite ? 'DELETE' : 'PUT',
261                     error: handleAjaxError,
262                     success: function() {
263                         $this.toggleClass('enabled', !isFavorite);
264                     },
265                     complete: function() {
266                         $this.prop('disabled', false);
267                     }
268                 });
269             }).qtip({
270                 hide: {
271                     fixed: true,
272                     delay: 500
273                 },
274                 content: {
275                     text: function() {
276                         if ($(this).hasClass('enabled')) {
277                             return $T("Remove from your favorites");
278                         } else {
279                             return format($T('<h3>Add to your favorites</h3><p>This will make events in this category visible on your <a href="{0}">Dashboard</a>.</p>'), [${url_for('users.user_dashboard') | n,j}]);
280                         }
281                     }
282                 }
283             })
284         });
285     </script>
286 % endif