Commit 7d38f517f475ad7981e0ea5dfa12948a09b924cd

Authored by Zambom
1 parent 343dfbb3

Adding youtube video creation (Changes to be made)

amadeus/static/js/resources.js
... ... @@ -2,35 +2,35 @@ $('#id_groups').multiSelect({
2 2 selectableHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder=' '>",
3 3 selectionHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder=''>",
4 4 afterInit: function(ms){
5   - var that = this,
6   - $selectableSearch = that.$selectableUl.prev(),
7   - $selectionSearch = that.$selectionUl.prev(),
8   - selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
9   - selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
10   -
11   - that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
12   - .on('keydown', function(e){
13   - if (e.which === 40){
14   - that.$selectableUl.focus();
15   - return false;
16   - }
17   - });
18   -
19   - that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
20   - .on('keydown', function(e){
21   - if (e.which == 40){
22   - that.$selectionUl.focus();
23   - return false;
24   - }
25   - });
  5 + var that = this,
  6 + $selectableSearch = that.$selectableUl.prev(),
  7 + $selectionSearch = that.$selectionUl.prev(),
  8 + selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
  9 + selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
  10 +
  11 + that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
  12 + .on('keydown', function(e){
  13 + if (e.which === 40){
  14 + that.$selectableUl.focus();
  15 + return false;
  16 + }
  17 + });
  18 +
  19 + that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
  20 + .on('keydown', function(e){
  21 + if (e.which == 40){
  22 + that.$selectionUl.focus();
  23 + return false;
  24 + }
  25 + });
26 26 },
27 27 afterSelect: function(){
28   - this.qs1.cache();
29   - this.qs2.cache();
  28 + this.qs1.cache();
  29 + this.qs2.cache();
30 30 },
31 31 afterDeselect: function(){
32   - this.qs1.cache();
33   - this.qs2.cache();
  32 + this.qs1.cache();
  33 + this.qs2.cache();
34 34 }
35 35 });// Used to create multi-select css style
36 36  
... ... @@ -38,52 +38,52 @@ $(&#39;#id_students&#39;).multiSelect({
38 38 selectableHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder=' '>",
39 39 selectionHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder=''>",
40 40 afterInit: function(ms){
41   - var that = this,
42   - $selectableSearch = that.$selectableUl.prev(),
43   - $selectionSearch = that.$selectionUl.prev(),
44   - selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
45   - selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
46   -
47   - that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
48   - .on('keydown', function(e){
49   - if (e.which === 40){
50   - that.$selectableUl.focus();
51   - return false;
52   - }
53   - });
54   -
55   - that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
56   - .on('keydown', function(e){
57   - if (e.which == 40){
58   - that.$selectionUl.focus();
59   - return false;
60   - }
61   - });
  41 + var that = this,
  42 + $selectableSearch = that.$selectableUl.prev(),
  43 + $selectionSearch = that.$selectionUl.prev(),
  44 + selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
  45 + selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
  46 +
  47 + that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
  48 + .on('keydown', function(e){
  49 + if (e.which === 40){
  50 + that.$selectableUl.focus();
  51 + return false;
  52 + }
  53 + });
  54 +
  55 + that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
  56 + .on('keydown', function(e){
  57 + if (e.which == 40){
  58 + that.$selectionUl.focus();
  59 + return false;
  60 + }
  61 + });
62 62 },
63 63 afterSelect: function(){
64   - this.qs1.cache();
65   - this.qs2.cache();
  64 + this.qs1.cache();
  65 + this.qs2.cache();
66 66 },
67 67 afterDeselect: function(){
68   - this.qs1.cache();
69   - this.qs2.cache();
  68 + this.qs1.cache();
  69 + this.qs2.cache();
70 70 }
71 71 });// Used to create multi-select css style
72 72  
73 73 $('.collapse').on('show.bs.collapse', function (e) {
74 74 if($(this).is(e.target)){
75   - var btn = $(this).parent().find('.fa-angle-right');
  75 + var btn = $(this).parent().find('.fa-angle-right');
76 76  
77   - btn.switchClass("fa-angle-right", "fa-angle-down", 250, "easeInOutQuad");
78   - }
  77 + btn.switchClass("fa-angle-right", "fa-angle-down", 250, "easeInOutQuad");
  78 + }
79 79 });
80 80  
81 81 $('.collapse').on('hide.bs.collapse', function (e) {
82 82 if($(this).is(e.target)){
83   - var btn = $(this).parent().find('.fa-angle-down');
  83 + var btn = $(this).parent().find('.fa-angle-down');
84 84  
85   - btn.switchClass("fa-angle-down", "fa-angle-right", 250, "easeInOutQuad");
86   - }
  85 + btn.switchClass("fa-angle-down", "fa-angle-right", 250, "easeInOutQuad");
  86 + }
87 87 });
88 88  
89 89 $('.begin_date_input').on('click', function () {
... ...
pendencies/models.py
... ... @@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
5 5 from topics.models import Resource
6 6  
7 7 class Pendencies(models.Model):
8   - action = models.CharField(_('Action'), max_length = 100, choices = (("view", _("Visualize")), ("create", _("Create")), ("answer", _("Answer")), ("access", _("Access"))), blank = True)
  8 + action = models.CharField(_('Action'), max_length = 100, choices = (("view", _("Visualize")), ("create", _("Create")), ("answer", _("Answer")), ("access", _("Access")), ("finish", _("Finish"))), blank = True)
9 9 begin_date = models.DateTimeField(_('Begin Date'), null = True, blank = True)
10 10 end_date = models.DateTimeField(_('End Date'), null = True, blank = True)
11 11 limit_date = models.DateTimeField(_('Limit Date'), null = True, blank = True)
... ...
youtube_video/forms.py
... ... @@ -12,6 +12,7 @@ from .models import YTVideo
12 12  
13 13 class YTVideoForm(forms.ModelForm):
14 14 subject = None
  15 + control_subject = forms.CharField(widget = forms.HiddenInput())
15 16  
16 17 def __init__(self, *args, **kwargs):
17 18 super(YTVideoForm, self).__init__(*args, **kwargs)
... ... @@ -22,6 +23,8 @@ class YTVideoForm(forms.ModelForm):
22 23 self.subject = self.instance.topic.subject
23 24 self.initial['tags'] = ", ".join(self.instance.tags.all().values_list("name", flat = True))
24 25  
  26 + self.initial['control_subject'] = self.subject.id
  27 +
25 28 self.fields['students'].queryset = self.subject.students.all()
26 29 self.fields['groups'].queryset = self.subject.group_subject.all()
27 30  
... ...
youtube_video/models.py
... ... @@ -20,7 +20,7 @@ class YTVideo(Resource):
20 20 return 'webpages:view'
21 21  
22 22 def update_link(self):
23   - return 'webpages:update'
  23 + return 'youtube:update'
24 24  
25 25 def delete_link(self):
26 26 return 'webpages:delete'
... ...
youtube_video/templates/youtube/_form.html
... ... @@ -102,98 +102,104 @@
102 102 </div>
103 103 </div>
104 104 <div id="notifications" class="panel-collapse collapse">
105   -
106   - <div class="notifies">
107   - <div style="text-align:left">
108   - {% render_field pendencies_form.id %}
109   - {% render_field pendencies_form.resource %}
110   - {% render_field pendencies_form.subject class='pend_subj' %}
111   -
112   - <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row">
113   - <label for="{{ pendencies_form.action.auto_id }}" class="pull-left action_label contol-label">
114   - {% trans 'Action not performed by the user' %}:
115   - </label>
116   - <div class="col-md-3">
117   - {% render_field pendencies_form.action class='form-control' %}
118   - </div>
  105 + {{ pendencies_form.management_form }}
  106 + {{ pendencies_form.non_form_errors }}
119 107  
120   - <br clear="all" />
  108 + {% for notify in pendencies_form %}
  109 + <div class="notifies">
  110 + <div style="text-align:left">
  111 + {% render_field notify.id %}
  112 + {% render_field notify.resource %}
  113 + {% render_field notify.subject class='pend_subj' %}
  114 +
  115 + {% if notify.instance.pk %}{{ notify.DELETE }}{% endif %}
  116 +
  117 + <div class="form-group{% if notify.has_error %} has-error {% endif %} row">
  118 + <label for="{{ notify.action.auto_id }}" class="pull-left action_label contol-label">
  119 + {% trans 'Action not performed by the user' %}:
  120 + </label>
  121 + <div class="col-md-3">
  122 + {% render_field notify.action class='form-control' %}
  123 + </div>
121 124  
122   - <span id="helpBlock" class="help-block">{{ pendencies_form.action.help_text }}</span>
123   -
124   - {% if pendencies_form.action.errors %}
125   - <div class="alert alert-danger alert-dismissible" role="alert">
126   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
127   - <span aria-hidden="true">&times;</span>
128   - </button>
129   - <ul>
130   - {% for error in pendencies_form.action.errors %}
131   - <li>{{ error }}</li>
132   - {% endfor %}
133   - </ul>
134   - </div>
135   - {% endif %}
136   - </div>
137   - <br clear="all" />
138   - <div class="row">
139   - <div class="col-md-12">
140   - <p>{% trans 'Wished period' %}: </p>
141   - </div>
142   - </div>
143   - <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row">
144   - <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox">
145   - <label>
146   - {% render_field pendencies_form.begin_date_check class="begin_date" %} {{ pendencies_form.begin_date.label }}
147   - </label>
148   - </div>
149   - <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
150   - {% render_field pendencies_form.begin_date class='form-control datetime-picker begin_date_input' %}
151   - </div>
152   - </div>
153   - <div class="row">
154   - <span id="helpBlock" class="help-block">{{ pendencies_form.begin_date.help_text }}</span>
155   -
156   - {% if pendencies_form.begin_date.errors %}
157   - <div class="alert alert-danger alert-dismissible" role="alert">
158   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
159   - <span aria-hidden="true">&times;</span>
160   - </button>
161   - <ul>
162   - {% for error in pendencies_form.begin_date.errors %}
163   - <li>{{ error }}</li>
164   - {% endfor %}
165   - </ul>
166   - </div>
167   - {% endif %}
168   - </div>
169   - <div class="form-group{% if pendencies_form.has_error %} has-error {% endif %} row">
170   - <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox">
171   - <label>
172   - {% render_field pendencies_form.end_date_check class="end_date" %} {{ pendencies_form.end_date.label }}
173   - </label>
174   - </div>
175   - <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
176   - {% render_field pendencies_form.end_date class='form-control datetime-picker end_date_input' %}
177   - </div>
178   - </div>
179   - <div class="row">
180   - <span id="helpBlock" class="help-block">{{ pendencies_form.end_date.help_text }}</span>
181   -
182   - {% if pendencies_form.end_date.errors %}
183   - <div class="alert alert-danger alert-dismissible" role="alert">
184   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
185   - <span aria-hidden="true">&times;</span>
186   - </button>
187   - <ul>
188   - {% for error in pendencies_form.end_date.errors %}
189   - <li>{{ error }}</li>
190   - {% endfor %}
191   - </ul>
192   - </div>
193   - {% endif %}
194   - </div>
  125 + <br clear="all" />
  126 +
  127 + <span id="helpBlock" class="help-block">{{ notify.action.help_text }}</span>
  128 +
  129 + {% if notify.action.errors %}
  130 + <div class="alert alert-danger alert-dismissible" role="alert">
  131 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  132 + <span aria-hidden="true">&times;</span>
  133 + </button>
  134 + <ul>
  135 + {% for error in notify.action.errors %}
  136 + <li>{{ error }}</li>
  137 + {% endfor %}
  138 + </ul>
  139 + </div>
  140 + {% endif %}
  141 + </div>
  142 + <br clear="all" />
  143 + <div class="row">
  144 + <div class="col-md-12">
  145 + <p>{% trans 'Wished period' %}: </p>
  146 + </div>
  147 + </div>
  148 + <div class="form-group{% if notify.has_error %} has-error {% endif %} row">
  149 + <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox">
  150 + <label>
  151 + {% render_field notify.begin_date_check class="begin_date" %} {{ notify.begin_date.label }}
  152 + </label>
  153 + </div>
  154 + <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
  155 + {% render_field notify.begin_date class='form-control datetime-picker begin_date_input' %}
  156 + </div>
  157 + </div>
  158 + <div class="row">
  159 + <span id="helpBlock" class="help-block">{{ notify.begin_date.help_text }}</span>
  160 +
  161 + {% if notify.begin_date.errors %}
  162 + <div class="alert alert-danger alert-dismissible" role="alert">
  163 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  164 + <span aria-hidden="true">&times;</span>
  165 + </button>
  166 + <ul>
  167 + {% for error in notify.begin_date.errors %}
  168 + <li>{{ error }}</li>
  169 + {% endfor %}
  170 + </ul>
  171 + </div>
  172 + {% endif %}
  173 + </div>
  174 + <div class="form-group{% if notify.has_error %} has-error {% endif %} row">
  175 + <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 checkbox">
  176 + <label>
  177 + {% render_field notify.end_date_check class="end_date" %} {{ notify.end_date.label }}
  178 + </label>
  179 + </div>
  180 + <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
  181 + {% render_field notify.end_date class='form-control datetime-picker end_date_input' %}
  182 + </div>
  183 + </div>
  184 + <div class="row">
  185 + <span id="helpBlock" class="help-block">{{ notify.end_date.help_text }}</span>
  186 +
  187 + {% if notify.end_date.errors %}
  188 + <div class="alert alert-danger alert-dismissible" role="alert">
  189 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  190 + <span aria-hidden="true">&times;</span>
  191 + </button>
  192 + <ul>
  193 + {% for error in notify.end_date.errors %}
  194 + <li>{{ error }}</li>
  195 + {% endfor %}
  196 + </ul>
  197 + </div>
  198 + {% endif %}
  199 + </div>
  200 + </div>
195 201 </div>
196   - </div>
  202 + {% endfor %}
197 203 </div>
198 204 </div>
199 205  
... ... @@ -328,6 +334,33 @@
328 334 </form>
329 335 <script type="text/javascript">
330 336 $(function() {
  337 + $('.notifies').formset({
  338 + addText: '{% trans "Add new notification" %}',
  339 + deleteText: '{% trans "Remove this" %}',
  340 + prefix: '{{ pendencies_form.prefix }}',
  341 + added: function (row) {
  342 + var locale = navigator.language || navigator.userLanguage;
  343 +
  344 + $(row).find('.datetime-picker').each(function () {
  345 + $(this).datetimepicker({
  346 + locale: locale
  347 + });
  348 + });
  349 + $('.begin_date_input').on('click', function () {
  350 + var checkbox = $(this).parent().parent().find('.begin_date');
  351 + $(checkbox).prop('checked', true);
  352 + });
  353 + $('.end_date_input').on('click', function () {
  354 + var checkbox = $(this).parent().parent().find('.end_date');
  355 + $(checkbox).prop('checked', true);
  356 + });
  357 + subject = $("#id_control_subject").val();
  358 + console.log(subject);
  359 + console.log($(row).find('.pend_subj'));
  360 + $(row).find('.pend_subj').val(subject);
  361 + }
  362 + });
  363 +
331 364 var begin_val = $('.begin_date_input').val(),
332 365 end_val = $('.end_date_input').val();
333 366  
... ...
youtube_video/templates/youtube/create.html
... ... @@ -10,6 +10,7 @@
10 10 {% block javascript %}
11 11 {{block.super}}
12 12 <script type="text/javascript" src="{% static "js/bootstrap-tagsinput.js" %} "></script>
  13 + <script type="text/javascript" src="{% static "js/jquery.formset.js" %} "></script>
13 14 {% endblock %}
14 15  
15 16 {% block breadcrumbs %}
... ...
youtube_video/templates/youtube/update.html 0 → 100644
... ... @@ -0,0 +1,37 @@
  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 + <script type="text/javascript" src="{% static "js/jquery.formset.js" %} "></script>
  14 +{% endblock %}
  15 +
  16 +{% block breadcrumbs %}
  17 + {{ block.super }}
  18 +
  19 + {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %}
  20 +
  21 + {% trans 'Edit: ' as bread %}
  22 + {% with bread|add:youtube.name as bread_slug %}
  23 + {% breadcrumb bread_slug 'youtube:update' topic.slug youtube.slug %}
  24 + {% endwith %}
  25 +{% endblock %}
  26 +
  27 +{% block content %}
  28 + <div class="card">
  29 + <div class="card-content">
  30 + <div class="card-body">
  31 + {% include 'youtube/_form.html' %}
  32 + </div>
  33 + </div>
  34 + </div>
  35 + <br clear="all" />
  36 + <br clear="all" />
  37 +{% endblock %}
... ...
youtube_video/urls.py
... ... @@ -5,4 +5,5 @@ from . import views
5 5  
6 6 urlpatterns = [
7 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'),
8 9 ]
... ...
youtube_video/views.py
... ... @@ -84,11 +84,14 @@ class CreateView(LoginRequiredMixin, generic.edit.CreateView):
84 84  
85 85 self.object.save()
86 86  
87   - pend_form = pendencies_form.save(commit = False)
88   - pend_form.resource = self.object
  87 + pendencies_form.instance = self.object
  88 + pendencies_form.save(commit = False)
89 89  
90   - if not pend_form.action == "":
91   - pend_form.save()
  90 + for pform in pendencies_form.forms:
  91 + pend_form = pform.save(commit = False)
  92 +
  93 + if not pend_form.action == "":
  94 + pend_form.save()
92 95  
93 96 return redirect(self.get_success_url())
94 97  
... ... @@ -108,13 +111,109 @@ class CreateView(LoginRequiredMixin, generic.edit.CreateView):
108 111 def get_success_url(self):
109 112 messages.success(self.request, _('The Youtube Video "%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))
110 113  
111   - success_url = reverse_lazy('webpages:view', kwargs = {'slug': self.object.slug})
  114 + #success_url = reverse_lazy('webpages:view', kwargs = {'slug': self.object.slug})
  115 +
  116 + #if self.object.show_window:
  117 + # self.request.session['resources'] = {}
  118 + # self.request.session['resources']['new_page'] = True
  119 + # self.request.session['resources']['new_page_url'] = reverse('webpages:window_view', kwargs = {'slug': self.object.slug})
  120 +
  121 + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
  122 +
  123 + return success_url
  124 +
  125 +class UpdateView(LoginRequiredMixin, generic.UpdateView):
  126 + login_url = reverse_lazy("users:login")
  127 + redirect_field_name = 'next'
  128 +
  129 + template_name = 'youtube/update.html'
  130 + model = YTVideo
  131 + form_class = YTVideoForm
  132 + context_object_name = 'youtube'
  133 +
  134 + def dispatch(self, request, *args, **kwargs):
  135 + slug = self.kwargs.get('topic_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(UpdateView, self).dispatch(request, *args, **kwargs)
  142 +
  143 + def get(self, request, *args, **kwargs):
  144 + self.object = self.get_object()
  145 +
  146 + form_class = self.get_form_class()
  147 + form = self.get_form(form_class)
  148 +
  149 + slug = self.kwargs.get('topic_slug', '')
  150 + topic = get_object_or_404(Topic, slug = slug)
  151 +
  152 + pendencies_form = InlinePendenciesFormset(instance=self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("finish", _("Finish"))]}])
  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 = self.get_object()
  158 +
  159 + form_class = self.get_form_class()
  160 + form = self.get_form(form_class)
  161 +
  162 + slug = self.kwargs.get('topic_slug', '')
  163 + topic = get_object_or_404(Topic, slug = slug)
  164 +
  165 + pendencies_form = InlinePendenciesFormset(self.request.POST, instance = self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("finish", _("Finish"))]}])
  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 form_invalid(self, form, pendencies_form):
  173 + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form))
  174 +
  175 + def form_valid(self, form, pendencies_form):
  176 + self.object = form.save(commit = False)
  177 +
  178 + if not self.object.topic.visible and not self.object.topic.repository:
  179 + self.object.visible = False
  180 +
  181 + self.object.save()
  182 +
  183 + pendencies_form.instance = self.object
  184 + pendencies_form.save(commit = False)
  185 +
  186 + for form in pendencies_form.forms:
  187 + pend_form = form.save(commit = False)
  188 +
  189 + if not pend_form.action == "":
  190 + pend_form.save()
  191 +
  192 + return redirect(self.get_success_url())
  193 +
  194 + def get_context_data(self, **kwargs):
  195 + context = super(UpdateView, self).get_context_data(**kwargs)
  196 +
  197 + context['title'] = _('Update YouTube Video')
  198 +
  199 + slug = self.kwargs.get('topic_slug', '')
  200 + topic = get_object_or_404(Topic, slug = slug)
  201 +
  202 + context['topic'] = topic
  203 + context['subject'] = topic.subject
  204 +
  205 + return context
  206 +
  207 + def get_success_url(self):
  208 + messages.success(self.request, _('The YouTube Video "%s" was updated successfully!')%(self.object.name))
  209 +
  210 + #success_url = reverse_lazy('webpages:view', kwargs = {'slug': self.object.slug})
112 211  
113   - if self.object.show_window:
114   - self.request.session['resources'] = {}
115   - self.request.session['resources']['new_page'] = True
116   - self.request.session['resources']['new_page_url'] = reverse('webpages:window_view', kwargs = {'slug': self.object.slug})
  212 + #if self.object.show_window:
  213 + # self.request.session['resources'] = {}
  214 + # self.request.session['resources']['new_page'] = True
  215 + # self.request.session['resources']['new_page_url'] = reverse('webpages:window_view', kwargs = {'slug': self.object.slug})
117 216  
118   - success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
  217 + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
119 218  
120 219 return success_url
121 220 \ No newline at end of file
... ...