def response_add(self, request, obj, post_url_continue='../%s/'): result = super(PageAdmin, self).response_add(request, obj, post_url_continue) if "_continue" in request.POST: return HttpResponseRedirect(post_url_continue % obj._get_pk_val() + get_query_string(request.GET, remove=['type', 'parent'], addq=True)) if "_addanother" in request.POST: return HttpResponseRedirect(request.path + get_query_string(request.GET, addq=True)) if request.GET.get('destination'): dest_url = self.parse_destination(request, obj) return HttpResponseRedirect(dest_url) return result
def __init__(self, request, model, *args): # Блок определения ссылок списка для строк "На уровень в верх" и "В корень" self.list_toroot_link = None self.list_toup_link = None if request.scms['page'].id: self.list_toroot_link = self.list_toup_link = get_query_string( request.GET, remove=['parent__id__exact'], addq=True) if request.scms['page'].parent_id: self.list_toup_link = get_query_string( request.GET, new_params={ 'parent__id__exact': str(request.scms['page'].parent_id) }, addq=True) super(SCMSChangeList, self).__init__(request, model, *args)
def response_change(self, request, obj): result = super(PageAdmin, self).response_change(request, obj) if "_continue" in request.POST: if IS_POPUP_VAR in request.POST: return HttpResponseRedirect(request.path + get_query_string(request.GET, new_params={'_popup': 1}, addq=True)) else: return HttpResponseRedirect(request.path + get_query_string(request.GET, addq=True)) elif "_saveasnew" in request.POST: pass # не реализовано elif "_addanother" in request.POST: return HttpResponseRedirect(result['location'] + '' + get_query_string(request.GET, new_params={'parent': str(obj.parent_id), 'type': obj.type}, remove=['language',], addq=True)) if request.GET.get('destination'): dest_url = self.parse_destination(request, obj) return HttpResponseRedirect(dest_url) return result
def update_language_tab_context(self, request, obj=None, context=None): """ Функция обновления контекста шаблона на основании языковых настроек. """ if not context: context = {} language = get_language_from_request(request, obj) context.update({ 'langgetvars': get_query_string(request.GET, remove=['language'], addq=False), 'language': language, 'traduction_language': settings.SCMS_LANGUAGES, 'show_language_tabs': len(settings.SCMS_LANGUAGES) > 1, }) return context
def render(self, context): param_to_add = {} for key, value in self.param_to_add.items(): new_key = key if isinstance(key, FilterExpression): new_key = key.resolve(context, True) new_key = new_key==None and key.token or new_key if isinstance(value, FilterExpression): new_value = value.resolve(context, True) param_to_add[new_key] = new_value==None and value.token or new_value else: param_to_add[new_key] = value param_to_remove = [] for value in self.param_to_remove: if isinstance(value, FilterExpression): new_value = value.resolve(context, True) param_to_remove.append(new_value==None and value.token or new_value) return get_query_string(context['request'].GET, param_to_add, param_to_remove)
def adminlist_title(self, obj): content_type = scms.site.get_content_type(obj.type) caption = '<strong>%s</strong>' % obj.title if content_type and (content_type.children or obj.nchildren): caption = '<a href="%s">%s</a>' % (get_query_string(self._request.GET, new_params={'parent__id__exact': str(obj.id)}, remove=['parent__id__exact'], addq=True), caption) return mark_safe(caption)