Commit b69f93287f6a25106fec97d3d6ef543221bb454c
1 parent
9021fd31
Exists in
master
and in
3 other branches
Criando front end da web conferencia
Showing
10 changed files
with
1071 additions
and
3 deletions
Show diff stats
amadeus/urls.py
... | ... | @@ -49,6 +49,8 @@ urlpatterns = [ |
49 | 49 | url(r'^s3direct/', include('s3direct.urls')), |
50 | 50 | url(r'^summernote/', include('django_summernote.urls')), |
51 | 51 | url(r'session_security/', include('session_security.urls')), |
52 | + url(r'^webconferences/', include('webconference.urls', namespace = 'webconferences')), | |
53 | + | |
52 | 54 | ] |
53 | 55 | |
54 | 56 | if settings.DEBUG: | ... | ... |
... | ... | @@ -0,0 +1,97 @@ |
1 | +# coding=utf-8 | |
2 | +from django import forms | |
3 | +from django.utils.translation import ugettext_lazy as _ | |
4 | +from django.utils.html import strip_tags | |
5 | + | |
6 | +from subjects.models import Tag | |
7 | + | |
8 | +from .models import Webconference | |
9 | + | |
10 | +class WebconferenceForm(forms.ModelForm): | |
11 | + subject = None | |
12 | + | |
13 | + def __init__(self, *args, **kwargs): | |
14 | + super(WebconferenceForm, self).__init__(*args, **kwargs) | |
15 | + | |
16 | + self.subject = kwargs['initial'].get('subject', None) | |
17 | + | |
18 | + if self.instance.id: | |
19 | + self.subject = self.instance.topic.subject | |
20 | + self.initial['tags'] = ", ".join(self.instance.tags.all().values_list("name", flat = True)) | |
21 | + | |
22 | + self.fields['students'].queryset = self.subject.students.all() | |
23 | + self.fields['groups'].queryset = self.subject.group_subject.all() | |
24 | + | |
25 | + tags = forms.CharField(label = _('Tags'), required = False) | |
26 | + | |
27 | + class Meta: | |
28 | + model = Webconference | |
29 | + fields = ['name', 'presentation', 'start', 'end', 'brief_description', 'all_students', 'students', 'groups', 'show_window', 'visible'] | |
30 | + labels = { | |
31 | + 'name': _('Web Conference Title'), | |
32 | + 'presentation': _('Presentation'), | |
33 | + } | |
34 | + widgets = { | |
35 | + 'presentation': forms.Textarea, | |
36 | + 'brief_description': forms.Textarea, | |
37 | + 'students': forms.SelectMultiple, | |
38 | + 'groups': forms.SelectMultiple, | |
39 | + } | |
40 | + | |
41 | + def clean_name(self): | |
42 | + name = self.cleaned_data.get('name', '') | |
43 | + | |
44 | + topics = self.subject.topic_subject.all() | |
45 | + | |
46 | + for topic in topics: | |
47 | + if self.instance.id: | |
48 | + same_name = topic.resource_topic.filter(name__unaccent__iexact = name).exclude(id = self.instance.id).count() | |
49 | + else: | |
50 | + same_name = topic.resource_topic.filter(name__unaccent__iexact = name).count() | |
51 | + | |
52 | + if same_name > 0: | |
53 | + self._errors['name'] = [_('This subject already has a webpage with this name')] | |
54 | + | |
55 | + return ValueError | |
56 | + | |
57 | + return name | |
58 | + | |
59 | + # def clean_content(self): | |
60 | + # content = self.cleaned_data.get('content', '') | |
61 | + # cleaned_content = strip_tags(content) | |
62 | + # | |
63 | + # if cleaned_content == '': | |
64 | + # self._errors['content'] = [_('This field is required.')] | |
65 | + # | |
66 | + # return ValueError | |
67 | + # | |
68 | + # return content | |
69 | + | |
70 | + def save(self, commit = True): | |
71 | + super(WebpageForm, self).save(commit = True) | |
72 | + | |
73 | + self.instance.save() | |
74 | + | |
75 | + previous_tags = self.instance.tags.all() | |
76 | + | |
77 | + tags = self.cleaned_data['tags'].split(",") | |
78 | + | |
79 | + #Excluding unwanted tags | |
80 | + for prev in previous_tags: | |
81 | + if not prev.name in tags: | |
82 | + self.instance.tags.remove(prev) | |
83 | + | |
84 | + for tag in tags: | |
85 | + tag = tag.strip() | |
86 | + | |
87 | + exist = Tag.objects.filter(name = tag).exists() | |
88 | + | |
89 | + if exist: | |
90 | + new_tag = Tag.objects.get(name = tag) | |
91 | + else: | |
92 | + new_tag = Tag.objects.create(name = tag) | |
93 | + | |
94 | + if not new_tag in self.instance.tags.all(): | |
95 | + self.instance.tags.add(new_tag) | |
96 | + | |
97 | + return self.instance | ... | ... |
webconference/models.py
1 | 1 | from django.db import models |
2 | +from django.utils.translation import ugettext_lazy as _ | |
3 | +from django.core.urlresolvers import reverse_lazy | |
2 | 4 | |
3 | -# Create your models here. | |
5 | +from topics.models import Resource | |
6 | + | |
7 | +class Webconference(Resource): | |
8 | + presentation = models.TextField(_('Presentation'), blank = True) | |
9 | + start = models.DateTimeField(_('Start date/hour')) | |
10 | + end = models.DateTimeField(_('End date/hour')) | |
11 | + | |
12 | + class Meta: | |
13 | + verbose_name = _('Web Conference') | |
14 | + verbose_name_plural = _('Web Conferences') | |
15 | + | |
16 | + def __str__(self): | |
17 | + return self.name | |
18 | + | |
19 | + # def access_link(self): | |
20 | + # if self.show_window: | |
21 | + # return reverse_lazy('webpages:window_view', args = (), kwargs = {'slug': self.slug}) | |
22 | + # | |
23 | + # return reverse_lazy('webpages:view', args = (), kwargs = {'slug': self.slug}) | |
24 | + def update_link(self): | |
25 | + return 'webconferences:update' | |
26 | + | |
27 | + def delete_link(self): | |
28 | + return 'webconferences:delete' | |
29 | + | |
30 | + def delete_message(self): | |
31 | + return _('Are you sure you want delete the webpage') | ... | ... |
... | ... | @@ -0,0 +1,388 @@ |
1 | +{% load static i18n %} | |
2 | +{% load widget_tweaks %} | |
3 | + | |
4 | +<form method="post" action="" enctype="multipart/form-data"> | |
5 | + {% csrf_token %} | |
6 | + | |
7 | + {% render_field form.control_subject %} | |
8 | + | |
9 | + <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> | |
10 | + <label for="{{ form.name.auto_id }}">{{ form.name.label }} <span>*</span></label> | |
11 | + {% render_field form.name class='form-control' %} | |
12 | + | |
13 | + <span id="helpBlock" class="help-block">{{ form.name.help_text }}</span> | |
14 | + | |
15 | + {% if form.name.errors %} | |
16 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
17 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
18 | + <span aria-hidden="true">×</span> | |
19 | + </button> | |
20 | + <ul> | |
21 | + {% for error in form.name.errors %} | |
22 | + <li>{{ error }}</li> | |
23 | + {% endfor %} | |
24 | + </ul> | |
25 | + </div> | |
26 | + {% endif %} | |
27 | + </div> | |
28 | + | |
29 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
30 | + <label for="{{ form.presentation.auto_id }}">{{ form.presentation.label }}</label> | |
31 | + {% render_field form.presentation class='form-control text_wysiwyg' %} | |
32 | + | |
33 | + <span id="helpBlock" class="help-block">{{ form.presentation.help_text }}</span> | |
34 | + | |
35 | + {% if form.presentation.errors %} | |
36 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
37 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
38 | + <span aria-hidden="true">×</span> | |
39 | + </button> | |
40 | + <ul> | |
41 | + {% for error in form.presentation.errors %} | |
42 | + <li>{{ error }}</li> | |
43 | + {% endfor %} | |
44 | + </ul> | |
45 | + </div> | |
46 | + {% endif %} | |
47 | + </div> | |
48 | + | |
49 | + | |
50 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
51 | + <label for="{{ form.start.auto_id }}">{{ form.start.label }} <span>*</span></label> | |
52 | + {% render_field form.start class='form-control datetime-picker' %} | |
53 | + | |
54 | + <span id="helpBlock" class="help-block">{{ form.start.help_text }}</span> | |
55 | + | |
56 | + {% if form.start.errors %} | |
57 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
58 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
59 | + <span aria-hidden="true">×</span> | |
60 | + </button> | |
61 | + <ul> | |
62 | + {% for error in form.start.errors %} | |
63 | + <li>{{ error }}</li> | |
64 | + {% endfor %} | |
65 | + </ul> | |
66 | + </div> | |
67 | + {% endif %} | |
68 | + </div> | |
69 | + | |
70 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
71 | + <label for="{{ form.end.auto_id }}">{{ form.end.label }} <span>*</span></label> | |
72 | + {% render_field form.end class='form-control datetime-picker' %} | |
73 | + | |
74 | + <span id="helpBlock" class="help-block">{{ form.end.help_text }}</span> | |
75 | + | |
76 | + {% if form.end.errors %} | |
77 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
78 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
79 | + <span aria-hidden="true">×</span> | |
80 | + </button> | |
81 | + <ul> | |
82 | + {% for error in form.end.errors %} | |
83 | + <li>{{ error }}</li> | |
84 | + {% endfor %} | |
85 | + </ul> | |
86 | + </div> | |
87 | + {% endif %} | |
88 | + </div> | |
89 | + | |
90 | + <legend>{% trans 'Common resources settings' %}</legend> | |
91 | + | |
92 | + <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> | |
93 | + <label for="{{ form.brief_description.auto_id }}">{{ form.brief_description.label }}</label> | |
94 | + {% render_field form.brief_description class='form-control text_wysiwyg' %} | |
95 | + | |
96 | + <span id="helpBlock" class="help-block">{{ form.brief_description.help_text }}</span> | |
97 | + | |
98 | + {% if form.brief_description.errors %} | |
99 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
100 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
101 | + <span aria-hidden="true">×</span> | |
102 | + </button> | |
103 | + <ul> | |
104 | + {% for error in form.brief_description.errors %} | |
105 | + <li>{{ error }}</li> | |
106 | + {% endfor %} | |
107 | + </ul> | |
108 | + </div> | |
109 | + {% endif %} | |
110 | + </div> | |
111 | + | |
112 | + <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> | |
113 | + <label for="{{ form.tags.auto_id }}">{{ form.tags.label }}</label> | |
114 | + {% render_field form.tags class='form-control' data-role="tagsinput" %} | |
115 | + | |
116 | + <span id="helpBlock" class="help-block">{{ form.tags.help_text }}</span> | |
117 | + | |
118 | + {% if form.tags.errors %} | |
119 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
120 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
121 | + <span aria-hidden="true">×</span> | |
122 | + </button> | |
123 | + <ul> | |
124 | + {% for error in form.tags.errors %} | |
125 | + <li>{{ error }}</li> | |
126 | + {% endfor %} | |
127 | + </ul> | |
128 | + </div> | |
129 | + {% endif %} | |
130 | + </div> | |
131 | + | |
132 | + <div class="panel-group" id="professors_accordion" role="tablist" aria-multiselectable="true"> | |
133 | + <div class="panel panel-info"> | |
134 | + <div class="panel-heading"> | |
135 | + <div class="row"> | |
136 | + <div class="col-md-12"> | |
137 | + <a data-parent="#professors_accordion" data-toggle="collapse" href="#notifications"> | |
138 | + <h4 class="panel-title"> | |
139 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button><label>{% trans 'Pendencies Notifications' %}</label> | |
140 | + </h4> | |
141 | + </a> | |
142 | + </div> | |
143 | + </div> | |
144 | + </div> | |
145 | + <div id="notifications" class="panel-collapse collapse"> | |
146 | + | |
147 | + <div class="notifies"> | |
148 | + <div style="text-align:left"> | |
149 | + {% render_field pendencies_form.id %} | |
150 | + {% render_field pendencies_form.resource %} | |
151 | + {% render_field pendencies_form.subject class='pend_subj' %} | |
152 | + | |
153 | + <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row"> | |
154 | + <label for="{{ pendencies_form.action.auto_id }}" class="pull-left action_label contol-label"> | |
155 | + {% trans 'Action not performed by the user' %}: | |
156 | + </label> | |
157 | + <div class="col-md-3"> | |
158 | + {% render_field pendencies_form.action class='form-control' %} | |
159 | + </div> | |
160 | + | |
161 | + <br clear="all" /> | |
162 | + | |
163 | + <span id="helpBlock" class="help-block">{{ pendencies_form.action.help_text }}</span> | |
164 | + | |
165 | + {% if pendencies_form.action.errors %} | |
166 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
167 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
168 | + <span aria-hidden="true">×</span> | |
169 | + </button> | |
170 | + <ul> | |
171 | + {% for error in pendencies_form.action.errors %} | |
172 | + <li>{{ error }}</li> | |
173 | + {% endfor %} | |
174 | + </ul> | |
175 | + </div> | |
176 | + {% endif %} | |
177 | + </div> | |
178 | + <br clear="all" /> | |
179 | + <div class="row"> | |
180 | + <div class="col-md-12"> | |
181 | + <p>{% trans 'Wished period' %}: </p> | |
182 | + </div> | |
183 | + </div> | |
184 | + <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row"> | |
185 | + <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox"> | |
186 | + <label> | |
187 | + {% render_field pendencies_form.begin_date_check class="begin_date" %} {{ pendencies_form.begin_date.label }} | |
188 | + </label> | |
189 | + </div> | |
190 | + <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"> | |
191 | + {% render_field pendencies_form.begin_date class='form-control datetime-picker begin_date_input' %} | |
192 | + </div> | |
193 | + </div> | |
194 | + <div class="row"> | |
195 | + <span id="helpBlock" class="help-block">{{ pendencies_form.begin_date.help_text }}</span> | |
196 | + | |
197 | + {% if pendencies_form.begin_date.errors %} | |
198 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
199 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
200 | + <span aria-hidden="true">×</span> | |
201 | + </button> | |
202 | + <ul> | |
203 | + {% for error in pendencies_form.begin_date.errors %} | |
204 | + <li>{{ error }}</li> | |
205 | + {% endfor %} | |
206 | + </ul> | |
207 | + </div> | |
208 | + {% endif %} | |
209 | + </div> | |
210 | + <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row"> | |
211 | + <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox"> | |
212 | + <label> | |
213 | + {% render_field pendencies_form.end_date_check class="end_date" %} {{ pendencies_form.end_date.label }} | |
214 | + </label> | |
215 | + </div> | |
216 | + <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"> | |
217 | + {% render_field pendencies_form.end_date class='form-control datetime-picker end_date_input' %} | |
218 | + </div> | |
219 | + </div> | |
220 | + <div class="row"> | |
221 | + <span id="helpBlock" class="help-block">{{ pendencies_form.end_date.help_text }}</span> | |
222 | + | |
223 | + {% if pendencies_form.end_date.errors %} | |
224 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
225 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
226 | + <span aria-hidden="true">×</span> | |
227 | + </button> | |
228 | + <ul> | |
229 | + {% for error in pendencies_form.end_date.errors %} | |
230 | + <li>{{ error }}</li> | |
231 | + {% endfor %} | |
232 | + </ul> | |
233 | + </div> | |
234 | + {% endif %} | |
235 | + </div> | |
236 | + </div> | |
237 | + </div> | |
238 | + </div> | |
239 | + </div> | |
240 | + | |
241 | + <div class="panel panel-info"> | |
242 | + <div class="panel-heading"> | |
243 | + <div class="row"> | |
244 | + <div class="col-md-12"> | |
245 | + <a data-parent="#professors_accordion" data-toggle="collapse" href="#students"> | |
246 | + <h4 class="panel-title"> | |
247 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button><label for="{{ form.students.auto_id }}">{{ form.students.label }}</label> | |
248 | + </h4> | |
249 | + </a> | |
250 | + </div> | |
251 | + </div> | |
252 | + </div> | |
253 | + <div id="students" class="panel-collapse collapse"> | |
254 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
255 | + <div class=" checkbox"> | |
256 | + <label for="{{ form.all_students.auto_id }}"> | |
257 | + {% render_field form.all_students %} {{ form.all_students.label }} | |
258 | + </label> | |
259 | + </div> | |
260 | + | |
261 | + <span id="helpBlock" class="help-block">{{ form.all_students.help_text }}</span> | |
262 | + | |
263 | + {% if form.all_students.errors %} | |
264 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
265 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
266 | + <span aria-hidden="true">×</span> | |
267 | + </button> | |
268 | + <ul> | |
269 | + {% for error in form.all_students.errors %} | |
270 | + <li>{{ error }}</li> | |
271 | + {% endfor %} | |
272 | + </ul> | |
273 | + </div> | |
274 | + {% endif %} | |
275 | + </div> | |
276 | + | |
277 | + <p><em>{% trans 'Attribute students to web conference' %}:</em></p> | |
278 | + {% render_field form.students class='form-control' %} | |
279 | + | |
280 | + <span id="helpBlock" class="help-block">{{ form.students.help_text }}</span> | |
281 | + | |
282 | + {% if form.students.errors %} | |
283 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
284 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
285 | + <span aria-hidden="true">×</span> | |
286 | + </button> | |
287 | + <ul> | |
288 | + {% for error in form.students.errors %} | |
289 | + <li>{{ error }}</li> | |
290 | + {% endfor %} | |
291 | + </ul> | |
292 | + </div> | |
293 | + {% endif %} | |
294 | + | |
295 | + <br clear="all" /> | |
296 | + | |
297 | + <p><em>{% trans 'Attribute groups to web conference' %}:</em></p> | |
298 | + {% render_field form.groups class='form-control' %} | |
299 | + | |
300 | + <span id="helpBlock" class="help-block">{{ form.groups.help_text }}</span> | |
301 | + | |
302 | + {% if form.groups.errors %} | |
303 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
304 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
305 | + <span aria-hidden="true">×</span> | |
306 | + </button> | |
307 | + <ul> | |
308 | + {% for error in form.groups.errors %} | |
309 | + <li>{{ error }}</li> | |
310 | + {% endfor %} | |
311 | + </ul> | |
312 | + </div> | |
313 | + {% endif %} | |
314 | + </div> | |
315 | + </div> | |
316 | + </div> | |
317 | + | |
318 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
319 | + <div class=" checkbox"> | |
320 | + <label for="{{ form.show_window.auto_id }}"> | |
321 | + {% render_field form.show_window %} {{ form.show_window.label }} | |
322 | + </label> | |
323 | + </div> | |
324 | + | |
325 | + <span id="helpBlock" class="help-block">{{ form.show_window.help_text }}</span> | |
326 | + | |
327 | + {% if form.show_window.errors %} | |
328 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
329 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
330 | + <span aria-hidden="true">×</span> | |
331 | + </button> | |
332 | + <ul> | |
333 | + {% for error in form.show_window.errors %} | |
334 | + <li>{{ error }}</li> | |
335 | + {% endfor %} | |
336 | + </ul> | |
337 | + </div> | |
338 | + {% endif %} | |
339 | + </div> | |
340 | + | |
341 | + <div class="form-group{% if form.has_error %} has-error {% endif %}"> | |
342 | + <div class=" checkbox"> | |
343 | + <label for="{{ form.visible.auto_id }}"> | |
344 | + {% render_field form.visible %} {{ form.visible.label }} | |
345 | + </label> | |
346 | + </div> | |
347 | + | |
348 | + <span id="helpBlock" class="help-block">{{ form.visible.help_text }}</span> | |
349 | + | |
350 | + {% if form.visible.errors %} | |
351 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
352 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
353 | + <span aria-hidden="true">×</span> | |
354 | + </button> | |
355 | + <ul> | |
356 | + {% for error in form.visible.errors %} | |
357 | + <li>{{ error }}</li> | |
358 | + {% endfor %} | |
359 | + </ul> | |
360 | + </div> | |
361 | + {% endif %} | |
362 | + </div> | |
363 | + | |
364 | + <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12"> | |
365 | + <div class="text-center"> | |
366 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-success" /> | |
367 | + </div> | |
368 | + </div> | |
369 | +</form> | |
370 | +<script type="text/javascript"> | |
371 | + $(function() { | |
372 | + var begin_val = $('.begin_date_input').val(), | |
373 | + end_val = $('.end_date_input').val(); | |
374 | + | |
375 | + if (begin_val != '') { | |
376 | + $(".begin_date").prop('checked', true); | |
377 | + } | |
378 | + | |
379 | + if (end_val != '') { | |
380 | + $(".end_date").prop('checked', true); | |
381 | + } | |
382 | + | |
383 | + {% if not pendencies_form.is_valid and pendencies_form.is_bound %} | |
384 | + $("#notifications").collapse('toggle'); | |
385 | + {% endif %} | |
386 | + }); | |
387 | +</script> | |
388 | +<script type="text/javascript" src="{% static 'js/resources.js' %}"></script> | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +{% extends 'subjects/view.html' %} | |
2 | + | |
3 | +{% load static i18n django_bootstrap_breadcrumbs %} | |
4 | + | |
5 | +{% block style %} | |
6 | + {{block.super}} | |
7 | + <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-tagsinput.css' %}"> | |
8 | +{% endblock %} | |
9 | + | |
10 | +{% block javascript %} | |
11 | + {{block.super}} | |
12 | + <script type="text/javascript" src="{% static 'js/bootstrap-tagsinput.js' %} "></script> | |
13 | +{% endblock %} | |
14 | + | |
15 | +{% block breadcrumbs %} | |
16 | + {{ block.super }} | |
17 | + | |
18 | + {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} | |
19 | + | |
20 | + {% trans 'Create Web Conference' as bread %} | |
21 | + {% breadcrumb bread 'webconferences:create' topic.slug %} | |
22 | +{% endblock %} | |
23 | + | |
24 | +{% block content %} | |
25 | + <div class="card"> | |
26 | + <div class="card-content"> | |
27 | + <div class="card-body"> | |
28 | + {% include 'webconference/_form.html' %} | |
29 | + </div> | |
30 | + </div> | |
31 | + </div> | |
32 | + <br clear="all" /> | |
33 | + <br clear="all" /> | |
34 | +{% endblock %} | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +{% extends 'subjects/view.html' %} | |
2 | + | |
3 | +{% load static i18n django_bootstrap_breadcrumbs %} | |
4 | + | |
5 | +{% block style %} | |
6 | + {{block.super}} | |
7 | + <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-tagsinput.css' %}"> | |
8 | +{% endblock %} | |
9 | + | |
10 | +{% block javascript %} | |
11 | + {{block.super}} | |
12 | + <script type="text/javascript" src="{% static 'js/bootstrap-tagsinput.js' %} "></script> | |
13 | +{% endblock %} | |
14 | + | |
15 | +{% block breadcrumbs %} | |
16 | + {{ block.super }} | |
17 | + | |
18 | + {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} | |
19 | + | |
20 | + {% trans 'Edit: ' as bread %} | |
21 | + {% with bread|add:webconference.name as bread_slug %} | |
22 | + {% breadcrumb bread_slug 'webconfrences:update' topic.slug webconference.slug %} | |
23 | + {% endwith %} | |
24 | +{% endblock %} | |
25 | + | |
26 | +{% block content %} | |
27 | + <div class="card"> | |
28 | + <div class="card-content"> | |
29 | + <div class="card-body"> | |
30 | + {% include 'webconference/_form.html' %} | |
31 | + </div> | |
32 | + </div> | |
33 | + </div> | |
34 | + <br clear="all" /> | |
35 | + <br clear="all" /> | |
36 | +{% endblock %} | ... | ... |
... | ... | @@ -0,0 +1,58 @@ |
1 | +{% extends 'subjects/view.html' %} | |
2 | + | |
3 | +{% load static i18n pagination permissions_tags subject_counter %} | |
4 | +{% load django_bootstrap_breadcrumbs %} | |
5 | + | |
6 | +{% block javascript%} | |
7 | + {{ block.super }} | |
8 | +{% endblock%} | |
9 | + | |
10 | +{% block breadcrumbs %} | |
11 | + {{ block.super }} | |
12 | + {% breadcrumb topic 'subjects:topic_view' subject.slug topic.slug %} | |
13 | + {% breadcrumb web conference 'webconferences:view' webconference.slug %} | |
14 | +{% endblock %} | |
15 | + | |
16 | +{% block content %} | |
17 | + {% if messages %} | |
18 | + {% for message in messages %} | |
19 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
20 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
21 | + <span aria-hidden="true">×</span> | |
22 | + </button> | |
23 | + <p>{{ message }}</p> | |
24 | + </div> | |
25 | + {% endfor %} | |
26 | + {% endif %} | |
27 | + | |
28 | + {% resource_permissions request.user webconference as has_resource_permissions %} | |
29 | + | |
30 | + {% if webconference.visible %} | |
31 | + <div class="panel panel-info topic-panel"> | |
32 | + <div class="panel-heading"> | |
33 | + {% elif has_resource_permissions %} | |
34 | + <div class="panel panel-info topic-panel-invisible"> | |
35 | + <div class="panel-heading panel-invisible"> | |
36 | + {% endif %} | |
37 | + <div class="row"> | |
38 | + <div class="col-md-12 category-header"> | |
39 | + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | |
40 | + <span>{{ webconference }}</span> | |
41 | + </h4> | |
42 | + | |
43 | + <div class="col-md-5 pull-right category-card-items"> | |
44 | + <a href="{% url 'mural:resource_view' webconference.slug %}" class="pull-right action_icon"> | |
45 | + <i class="fa fa-list" aria-hidden="true"></i> | |
46 | + {% resource_mural_number webconference request.user %} | |
47 | + </a> | |
48 | + </div> | |
49 | + </div> | |
50 | + </div> | |
51 | + </div> | |
52 | + <div id="{{subject.slug}}" class="panel-collapse in collapse category-panel-content"> | |
53 | + {% autoescape off %} | |
54 | + {{ webconference.content }} | |
55 | + {% endautoescape %} | |
56 | + </div> | |
57 | + </div> | |
58 | +{% endblock %} | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +{{ webconference.content|safe }} | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +from django.conf.urls import url | |
2 | +from django.contrib.auth import views as auth_views | |
3 | + | |
4 | +from . import views | |
5 | + | |
6 | +urlpatterns = [ | |
7 | + url(r'^create/(?P<slug>[\w_-]+)/$', views.CreateView.as_view(), name = 'create'), | |
8 | + url(r'^update/(?P<topic_slug>[\w_-]+)/(?P<slug>[\w_-]+)/$', views.UpdateView.as_view(), name = 'update'), | |
9 | + url(r'^delete/(?P<slug>[\w_-]+)/$', views.DeleteView.as_view(), name = 'delete'), | |
10 | + url(r'^window_view/(?P<slug>[\w_-]+)/$', views.NewWindowView.as_view(), name = 'window_view'), | |
11 | + url(r'^view/(?P<slug>[\w_-]+)/$', views.InsideView.as_view(), name = 'view'), | |
12 | +] | ... | ... |
webconference/views.py
1 | -from django.shortcuts import render | |
1 | +from django.shortcuts import get_object_or_404, redirect, render | |
2 | +from django.views import generic | |
3 | +from django.contrib import messages | |
4 | +from django.core.urlresolvers import reverse, reverse_lazy | |
5 | +from django.utils.translation import ugettext_lazy as _ | |
6 | +from django.contrib.auth.mixins import LoginRequiredMixin | |
2 | 7 | |
3 | -# Create your views here. | |
8 | +from amadeus.permissions import has_subject_permissions, has_resource_permissions | |
9 | + | |
10 | +import time | |
11 | +from log.models import Log | |
12 | +from log.mixins import LogMixin | |
13 | + | |
14 | +from topics.models import Topic | |
15 | + | |
16 | +from pendencies.forms import PendenciesForm | |
17 | + | |
18 | +from .forms import WebconferenceForm | |
19 | +from .models import Webconference | |
20 | + | |
21 | +class NewWindowView(LoginRequiredMixin, | |
22 | + # '''LogMixin,''' | |
23 | + generic.DetailView): | |
24 | + # log_component = 'resources' | |
25 | + # log_action = 'view' | |
26 | + # log_resource = 'webpage' | |
27 | + # log_context = {} | |
28 | + | |
29 | + login_url = reverse_lazy("users:login") | |
30 | + redirect_field_name = 'next' | |
31 | + | |
32 | + template_name = 'webconference/window_view.html' | |
33 | + model = Webconference | |
34 | + context_object_name = 'webconference' | |
35 | + | |
36 | + def dispatch(self, request, *args, **kwargs): | |
37 | + slug = self.kwargs.get('slug', '') | |
38 | + webconference = get_object_or_404(Webconference, slug = slug) | |
39 | + | |
40 | + if not has_resource_permissions(request.user, webconference): | |
41 | + return redirect(reverse_lazy('subjects:home')) | |
42 | + | |
43 | + return super(NewWindowView, self).dispatch(request, *args, **kwargs) | |
44 | + | |
45 | + def get_context_data(self, **kwargs): | |
46 | + context = super(NewWindowView, self).get_context_data(**kwargs) | |
47 | + | |
48 | + # self.log_context['category_id'] = self.object.topic.subject.category.id | |
49 | + # self.log_context['category_name'] = self.object.topic.subject.category.name | |
50 | + # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
51 | + # self.log_context['subject_id'] = self.object.topic.subject.id | |
52 | + # self.log_context['subject_name'] = self.object.topic.subject.name | |
53 | + # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
54 | + # self.log_context['topic_id'] = self.object.topic.id | |
55 | + # self.log_context['topic_name'] = self.object.topic.name | |
56 | + # self.log_context['topic_slug'] = self.object.topic.slug | |
57 | + # self.log_context['webpage_id'] = self.object.id | |
58 | + # self.log_context['webpage_name'] = self.object.name | |
59 | + # self.log_context['webpage_slug'] = self.object.slug | |
60 | + # self.log_context['timestamp_start'] = str(int(time.time())) | |
61 | + | |
62 | + # super(NewWindowView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
63 | + # | |
64 | + # self.request.session['log_id'] = Log.objects.latest('id').id | |
65 | + | |
66 | + return context | |
67 | + | |
68 | +class InsideView(LoginRequiredMixin, | |
69 | +# '''LogMixin,''' | |
70 | +generic.DetailView): | |
71 | + # log_component = 'resources' | |
72 | + # log_action = 'view' | |
73 | + # log_resource = 'webpage' | |
74 | + # log_context = {} | |
75 | + | |
76 | + login_url = reverse_lazy("users:login") | |
77 | + redirect_field_name = 'next' | |
78 | + | |
79 | + template_name = 'webconference/view.html' | |
80 | + model = Webconference | |
81 | + context_object_name = 'webconference' | |
82 | + | |
83 | + def dispatch(self, request, *args, **kwargs): | |
84 | + slug = self.kwargs.get('slug', '') | |
85 | + webconference = get_object_or_404(Webconference, slug = slug) | |
86 | + | |
87 | + if not has_resource_permissions(request.user, webconference): | |
88 | + return redirect(reverse_lazy('subjects:home')) | |
89 | + | |
90 | + return super(InsideView, self).dispatch(request, *args, **kwargs) | |
91 | + | |
92 | + def get_context_data(self, **kwargs): | |
93 | + context = super(InsideView, self).get_context_data(**kwargs) | |
94 | + | |
95 | + context['title'] = self.object.name | |
96 | + | |
97 | + context['topic'] = self.object.topic | |
98 | + context['subject'] = self.object.topic.subject | |
99 | + | |
100 | + # self.log_context['category_id'] = self.object.topic.subject.category.id | |
101 | + # self.log_context['category_name'] = self.object.topic.subject.category.name | |
102 | + # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
103 | + # self.log_context['subject_id'] = self.object.topic.subject.id | |
104 | + # self.log_context['subject_name'] = self.object.topic.subject.name | |
105 | + # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
106 | + # self.log_context['topic_id'] = self.object.topic.id | |
107 | + # self.log_context['topic_name'] = self.object.topic.name | |
108 | + # self.log_context['topic_slug'] = self.object.topic.slug | |
109 | + # self.log_context['webpage_id'] = self.object.id | |
110 | + # self.log_context['webpage_name'] = self.object.name | |
111 | + # self.log_context['webpage_slug'] = self.object.slug | |
112 | + # self.log_context['timestamp_start'] = str(int(time.time())) | |
113 | + # | |
114 | + # super(InsideView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
115 | + # | |
116 | + # self.request.session['log_id'] = Log.objects.latest('id').id | |
117 | + | |
118 | + return context | |
119 | + | |
120 | +class CreateView(LoginRequiredMixin, | |
121 | + # '''LogMixin,''' | |
122 | + generic.edit.CreateView): | |
123 | + # log_component = 'resources' | |
124 | + # log_action = 'create' | |
125 | + # log_resource = 'webpage' | |
126 | + # log_context = {} | |
127 | + | |
128 | + login_url = reverse_lazy("users:login") | |
129 | + redirect_field_name = 'next' | |
130 | + | |
131 | + template_name = 'webconference/create.html' | |
132 | + form_class = WebconferenceForm | |
133 | + | |
134 | + def dispatch(self, request, *args, **kwargs): | |
135 | + slug = self.kwargs.get('slug', '') | |
136 | + topic = get_object_or_404(Topic, slug = slug) | |
137 | + | |
138 | + if not has_subject_permissions(request.user, topic.subject): | |
139 | + return redirect(reverse_lazy('subjects:home')) | |
140 | + | |
141 | + return super(CreateView, self).dispatch(request, *args, **kwargs) | |
142 | + | |
143 | + def get(self, request, *args, **kwargs): | |
144 | + self.object = None | |
145 | + | |
146 | + form_class = self.get_form_class() | |
147 | + form = self.get_form(form_class) | |
148 | + | |
149 | + slug = self.kwargs.get('slug', '') | |
150 | + topic = get_object_or_404(Topic, slug = slug) | |
151 | + | |
152 | + pendencies_form = PendenciesForm(initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
153 | + | |
154 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
155 | + | |
156 | + def post(self, request, *args, **kwargs): | |
157 | + self.object = None | |
158 | + | |
159 | + form_class = self.get_form_class() | |
160 | + form = self.get_form(form_class) | |
161 | + | |
162 | + slug = self.kwargs.get('slug', '') | |
163 | + topic = get_object_or_404(Topic, slug = slug) | |
164 | + | |
165 | + pendencies_form = PendenciesForm(self.request.POST, initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
166 | + | |
167 | + if (form.is_valid() and pendencies_form.is_valid()): | |
168 | + return self.form_valid(form, pendencies_form) | |
169 | + else: | |
170 | + return self.form_invalid(form, pendencies_form) | |
171 | + | |
172 | + def get_initial(self): | |
173 | + initial = super(CreateView, self).get_initial() | |
174 | + | |
175 | + slug = self.kwargs.get('slug', '') | |
176 | + | |
177 | + topic = get_object_or_404(Topic, slug = slug) | |
178 | + initial['subject'] = topic.subject | |
179 | + | |
180 | + return initial | |
181 | + | |
182 | + def form_invalid(self, form, pendencies_form): | |
183 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
184 | + | |
185 | + def form_valid(self, form, pendencies_form): | |
186 | + self.object = form.save(commit = False) | |
187 | + | |
188 | + slug = self.kwargs.get('slug', '') | |
189 | + topic = get_object_or_404(Topic, slug = slug) | |
190 | + | |
191 | + self.object.topic = topic | |
192 | + self.object.order = topic.resource_topic.count() + 1 | |
193 | + | |
194 | + if not self.object.topic.visible and not self.object.topic.repository: | |
195 | + self.object.visible = False | |
196 | + | |
197 | + self.object.save() | |
198 | + | |
199 | + pend_form = pendencies_form.save(commit = False) | |
200 | + pend_form.resource = self.object | |
201 | + | |
202 | + if not pend_form.action == "": | |
203 | + pend_form.save() | |
204 | + | |
205 | + # self.log_context['category_id'] = self.object.topic.subject.category.id | |
206 | + # self.log_context['category_name'] = self.object.topic.subject.category.name | |
207 | + # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
208 | + # self.log_context['subject_id'] = self.object.topic.subject.id | |
209 | + # self.log_context['subject_name'] = self.object.topic.subject.name | |
210 | + # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
211 | + # self.log_context['topic_id'] = self.object.topic.id | |
212 | + # self.log_context['topic_name'] = self.object.topic.name | |
213 | + # self.log_context['topic_slug'] = self.object.topic.slug | |
214 | + # self.log_context['webpage_id'] = self.object.id | |
215 | + # self.log_context['webpage_name'] = self.object.name | |
216 | + # self.log_context['webpage_slug'] = self.object.slug | |
217 | + # | |
218 | + # super(CreateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
219 | + | |
220 | + return redirect(self.get_success_url()) | |
221 | + | |
222 | + def get_context_data(self, **kwargs): | |
223 | + context = super(CreateView, self).get_context_data(**kwargs) | |
224 | + | |
225 | + context['title'] = _('Create Web Conference') | |
226 | + | |
227 | + slug = self.kwargs.get('slug', '') | |
228 | + topic = get_object_or_404(Topic, slug = slug) | |
229 | + | |
230 | + context['topic'] = topic | |
231 | + context['subject'] = topic.subject | |
232 | + | |
233 | + return context | |
234 | + | |
235 | + def get_success_url(self): | |
236 | + messages.success(self.request, _('The Web conference "%s" was added to the Topic "%s" of the virtual environment "%s" successfully!')%(self.object.name, self.object.topic.name, self.object.topic.subject.name)) | |
237 | + | |
238 | + success_url = reverse_lazy('webconference:view', kwargs = {'slug': self.object.slug}) | |
239 | + | |
240 | + if self.object.show_window: | |
241 | + self.request.session['resources'] = {} | |
242 | + self.request.session['resources']['new_page'] = True | |
243 | + self.request.session['resources']['new_page_url'] = reverse('webconference:window_view', kwargs = {'slug': self.object.slug}) | |
244 | + | |
245 | + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
246 | + | |
247 | + return success_url | |
248 | + | |
249 | +class UpdateView(LoginRequiredMixin, | |
250 | +# ''' LogMixin,''' | |
251 | +generic.UpdateView): | |
252 | + # log_component = 'resources' | |
253 | + # log_action = 'update' | |
254 | + # log_resource = 'webpage' | |
255 | + # log_context = {} | |
256 | + | |
257 | + login_url = reverse_lazy("users:login") | |
258 | + redirect_field_name = 'next' | |
259 | + | |
260 | + template_name = 'webconference/update.html' | |
261 | + model = Webconference | |
262 | + form_class = WebconferenceForm | |
263 | + | |
264 | + def dispatch(self, request, *args, **kwargs): | |
265 | + slug = self.kwargs.get('topic_slug', '') | |
266 | + topic = get_object_or_404(Topic, slug = slug) | |
267 | + | |
268 | + if not has_subject_permissions(request.user, topic.subject): | |
269 | + return redirect(reverse_lazy('subjects:home')) | |
270 | + | |
271 | + return super(UpdateView, self).dispatch(request, *args, **kwargs) | |
272 | + | |
273 | + def get(self, request, *args, **kwargs): | |
274 | + self.object = self.get_object() | |
275 | + | |
276 | + form_class = self.get_form_class() | |
277 | + form = self.get_form(form_class) | |
278 | + | |
279 | + slug = self.kwargs.get('topic_slug', '') | |
280 | + topic = get_object_or_404(Topic, slug = slug) | |
281 | + | |
282 | + pend_form = self.object.pendencies_resource.all() | |
283 | + | |
284 | + if len(pend_form) > 0: | |
285 | + pendencies_form = PendenciesForm(instance = pend_form[0], initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
286 | + else: | |
287 | + pendencies_form = PendenciesForm(initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
288 | + | |
289 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
290 | + | |
291 | + def post(self, request, *args, **kwargs): | |
292 | + self.object = self.get_object() | |
293 | + | |
294 | + form_class = self.get_form_class() | |
295 | + form = self.get_form(form_class) | |
296 | + | |
297 | + slug = self.kwargs.get('topic_slug', '') | |
298 | + topic = get_object_or_404(Topic, slug = slug) | |
299 | + | |
300 | + pend_form = self.object.pendencies_resource.all() | |
301 | + | |
302 | + if len(pend_form) > 0: | |
303 | + pendencies_form = PendenciesForm(self.request.POST, instance = pend_form[0], initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
304 | + else: | |
305 | + pendencies_form = PendenciesForm(self.request.POST, initial = {'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize"))]}) | |
306 | + | |
307 | + if (form.is_valid() and pendencies_form.is_valid()): | |
308 | + return self.form_valid(form, pendencies_form) | |
309 | + else: | |
310 | + return self.form_invalid(form, pendencies_form) | |
311 | + | |
312 | + def form_invalid(self, form, pendencies_form): | |
313 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
314 | + | |
315 | + def form_valid(self, form, pendencies_form): | |
316 | + self.object = form.save(commit = False) | |
317 | + | |
318 | + if not self.object.topic.visible and not self.object.topic.repository: | |
319 | + self.object.visible = False | |
320 | + | |
321 | + self.object.save() | |
322 | + | |
323 | + pend_form = pendencies_form.save(commit = False) | |
324 | + pend_form.resource = self.object | |
325 | + | |
326 | + if not pend_form.action == "": | |
327 | + pend_form.save() | |
328 | + | |
329 | + # self.log_context['category_id'] = self.object.topic.subject.category.id | |
330 | + # self.log_context['category_name'] = self.object.topic.subject.category.name | |
331 | + # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
332 | + # self.log_context['subject_id'] = self.object.topic.subject.id | |
333 | + # self.log_context['subject_name'] = self.object.topic.subject.name | |
334 | + # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
335 | + # self.log_context['topic_id'] = self.object.topic.id | |
336 | + # self.log_context['topic_name'] = self.object.topic.name | |
337 | + # self.log_context['topic_slug'] = self.object.topic.slug | |
338 | + # self.log_context['webpage_id'] = self.object.id | |
339 | + # self.log_context['webpage_name'] = self.object.name | |
340 | + # self.log_context['webpage_slug'] = self.object.slug | |
341 | + # | |
342 | + # super(UpdateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
343 | + | |
344 | + return redirect(self.get_success_url()) | |
345 | + | |
346 | + def get_context_data(self, **kwargs): | |
347 | + context = super(UpdateView, self).get_context_data(**kwargs) | |
348 | + | |
349 | + context['title'] = _('Update Web Conference') | |
350 | + | |
351 | + slug = self.kwargs.get('topic_slug', '') | |
352 | + topic = get_object_or_404(Topic, slug = slug) | |
353 | + | |
354 | + context['topic'] = topic | |
355 | + context['subject'] = topic.subject | |
356 | + | |
357 | + return context | |
358 | + | |
359 | + def get_success_url(self): | |
360 | + messages.success(self.request, _('The Web conference "%s" was updated successfully!')%(self.object.name)) | |
361 | + | |
362 | + success_url = reverse_lazy('webconference:view', kwargs = {'slug': self.object.slug}) | |
363 | + | |
364 | + if self.object.show_window: | |
365 | + self.request.session['resources'] = {} | |
366 | + self.request.session['resources']['new_page'] = True | |
367 | + self.request.session['resources']['new_page_url'] = reverse('webconference:window_view', kwargs = {'slug': self.object.slug}) | |
368 | + | |
369 | + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
370 | + | |
371 | + return success_url | |
372 | + | |
373 | +class DeleteView(LoginRequiredMixin, | |
374 | +# ''' LogMixin,''' | |
375 | +generic.DeleteView): | |
376 | + # log_component = 'resources' | |
377 | + # log_action = 'delete' | |
378 | + # log_resource = 'webpage' | |
379 | + # log_context = {} | |
380 | + | |
381 | + login_url = reverse_lazy("users:login") | |
382 | + redirect_field_name = 'next' | |
383 | + | |
384 | + template_name = 'resources/delete.html' | |
385 | + model = Webconference | |
386 | + context_object_name = 'resource' | |
387 | + | |
388 | + def dispatch(self, request, *args, **kwargs): | |
389 | + slug = self.kwargs.get('slug', '') | |
390 | + webconference = get_object_or_404(Webconference, slug = slug) | |
391 | + | |
392 | + if not has_subject_permissions(request.user, webconference.topic.subject): | |
393 | + return redirect(reverse_lazy('subjects:home')) | |
394 | + | |
395 | + return super(DeleteView, self).dispatch(request, *args, **kwargs) | |
396 | + | |
397 | + def get_success_url(self): | |
398 | + messages.success(self.request, _('The web conference "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) | |
399 | + | |
400 | + # self.log_context['category_id'] = self.object.topic.subject.category.id | |
401 | + # self.log_context['category_name'] = self.object.topic.subject.category.name | |
402 | + # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
403 | + # self.log_context['subject_id'] = self.object.topic.subject.id | |
404 | + # self.log_context['subject_name'] = self.object.topic.subject.name | |
405 | + # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
406 | + # self.log_context['topic_id'] = self.object.topic.id | |
407 | + # self.log_context['topic_name'] = self.object.topic.name | |
408 | + # self.log_context['topic_slug'] = self.object.topic.slug | |
409 | + # self.log_context['webpage_id'] = self.object.id | |
410 | + # self.log_context['webpage_name'] = self.object.name | |
411 | + # self.log_context['webpage_slug'] = self.object.slug | |
412 | + # | |
413 | + # super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
414 | + | |
415 | + return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | ... | ... |