def news_list(request): type = request.GET.get('type', u'public') if type == u'prof': news_page = get_page( request, News.objects.filter(type=1).order_by('-create_date')) elif type == u'public': news_page = get_page( request, News.objects.filter(type=0).order_by('-create_date')) else: news_page = get_page( request, News.objects.filter(type=2).order_by('-create_date')) news_contents = list( NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {'news': news} for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'news/administration/news_list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def list(request, parent=None): if not request.user.has_module_perms("participants"): return HttpResponseForbidden() if parent: parent = get_object_or_404(models.Library, id=parent) libraries_page = get_page(request, models.Library.objects.filter(parent=parent)) else: libraries_page = get_page(request, models.Library.objects.filter(parent=None)) return render( request, "participants/administration/libraries_list.html", {"parent": parent, "libraries_page": libraries_page} )
def list(request, parent=None): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() q = Q() if parent: parent = get_object_or_404(models.Library, id=parent) q &= Q(parent=parent) else: q &= Q(parent=None) filter_from = forms.LibraryFilterForm(request.GET, prefix='ftr') if filter_from.is_valid(): if filter_from.cleaned_data['org_type']: q &= Q(org_type=filter_from.cleaned_data['org_type']) libraries_page = get_page(request, models.Library.objects.filter(q)) return render( request, 'participants/administration/libraries_list.html', { 'parent': parent, 'libraries_page': libraries_page, 'filter_from': filter_from, })
def library_wifi_list(request, managed_libraries=[]): districts = [] for managed_library in managed_libraries: districts.append(managed_library.district_id) districts_form = forms.get_district_form(districts)(request.GET, prefix='sdf') select_libraries_qs = _get_user_manager_orgs_qs(managed_libraries) select_library_form = forms.get_add_user_library_form(select_libraries_qs)(request.GET, prefix='slf') wifi_attr_form = forms.WiFiPointAttrForm(request.GET, prefix='waf') q = Q() if districts: q &= Q(library__in=select_libraries_qs) if districts_form.is_valid(): district = districts_form.cleaned_data['district'] if district: q &= Q(library__district=district) if select_library_form.is_valid(): selected_library = select_library_form.cleaned_data['library'] libraries_ids = [selected_library.id] for descendant in selected_library.get_descendants().values('id'): libraries_ids.append(descendant['id']) q &= Q(library__in=libraries_ids) if wifi_attr_form.is_valid(): if wifi_attr_form.cleaned_data['mac']: q &= Q(mac__icontains=wifi_attr_form.cleaned_data['mac']) if wifi_attr_form.cleaned_data['comments']: comment_parts = wifi_attr_form.cleaned_data['comments'].split(' ') q_comments = Q() for comment_part in comment_parts: q_comments &= Q(comments__icontains=comment_part) q &= q_comments if wifi_attr_form.cleaned_data['status']: q &= Q(status=wifi_attr_form.cleaned_data['status']) library_wifi_page = get_page( request, models.WiFiPoint.objects.select_related('library', 'library__district').filter(q), 20 ) total_wifi = models.WiFiPoint.objects.all().count() total_enabled_wifi = models.WiFiPoint.objects.filter(status='enabled').count() total_disabled_wifi = models.WiFiPoint.objects.filter(status='disabled').count() return render(request, 'participants/administration/library_wifi_list.html', { 'select_library_form': select_library_form, 'districts_form': districts_form, 'wifi_attr_form': wifi_attr_form, 'library_wifi_page': library_wifi_page, 'total_wifi': total_wifi, 'total_enabled_wifi': total_enabled_wifi, 'total_disabled_wifi': total_disabled_wifi, })
def my_questions(request): questions_page = get_page( request, Question.objects.filter(user=request.user).order_by('-create_date'), 10) return render(request, 'ask_librarian/frontend/my_questions.html', {'questions_page': questions_page})
def index(request, library_code): library = get_object_or_404(Library, code=library_code) polls_page = get_page( request, models.Poll.objects.filter(publicated=True, library=library).order_by('-create_date')) poll_contents = list( models.PollContent.objects.filter(poll__in=list( polls_page.object_list), lang=get_language()[:2])) t_dict = {} for poll in polls_page.object_list: t_dict[poll.id] = {'poll': poll} for poll_content in poll_contents: t_dict[poll_content.poll_id]['poll'].poll_content = poll_content return render( request, 'participant_photopolls/frontend/list.html', { 'library': library, 'polls_list': polls_page.object_list, 'polls_page': polls_page, })
def filer_by_date(request, library_code, day='', month='', year=''): library = get_object_or_404(Library, code=library_code) events_page = get_page(request, models.Event.objects.filter( library=library, active=True, start_date__year=year, start_date__month=month, start_date__day=day ).prefetch_related('age_category', 'event_type').order_by('-create_date')) event_contents = list(models.EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content date = datetime( year=int(year), month=int(month), day=int(day) ) return render(request, 'participant_events/frontend/list.html', { 'library': library, 'events_list': events_page.object_list, 'events_page': events_page, 'date': date })
def index(request, library_code): library = get_object_or_404(Library, code=library_code) polls_page = get_page( request, models.Poll.objects.filter( publicated=True, library=library ).order_by('-create_date') ) poll_contents = list( models.PollContent.objects.filter( poll__in=list(polls_page.object_list), lang=get_language()[:2] )) t_dict = {} for poll in polls_page.object_list: t_dict[poll.id] = {'poll': poll} for poll_content in poll_contents: t_dict[poll_content.poll_id]['poll'].poll_content = poll_content return render(request, 'participant_photopolls/frontend/list.html', { 'library': library, 'polls_list': polls_page.object_list, 'polls_page': polls_page, })
def index(request, library_code): library = get_object_or_404(Library, code=library_code) events_page = get_page( request, models.Event.objects.filter( active=True, library=library ).prefetch_related('age_category', 'event_type').order_by('-create_date') ) event_contents = list( models.EventContent.objects.filter( event__in=list(events_page.object_list), lang=get_language()[:2] )) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'participant_events/frontend/list.html', { 'library': library, 'events_list': events_page.object_list, 'events_page': events_page, })
def pages_list(request, parent=None): if parent: parent = get_object_or_404(Page, id=parent) pages_page = get_page(request, Page.objects.filter(parent=parent)) pages_page.object_list = list(pages_page.object_list) contents = list( Content.objects.filter(page__in=pages_page.object_list, lang=get_language()[:2])) pages_dict = {} for page in pages_page.object_list: pages_dict[page.id] = {'page': page} for content in contents: pages_dict[content.page_id]['page'].content = content # pages = [page['page'] for page in pages_dict.values()] return render( request, 'pages/administration/pages_list.html', { 'parent': parent, 'pages': pages_page.object_list, 'pages_page': pages_page, })
def index(request): cur_language = translation.get_language() items_page = get_page( request, ItemContent.objects.prefetch_related('item').filter( item__publicated=True, lang=cur_language).order_by('-item__create_date')) nd = {} for item in items_page.object_list: nd[item.item.id_in_catalog] = item records_ids = [] for items_lis in items_page.object_list: records_ids.append(items_lis.item.id_in_catalog) records = get_records(records_ids) for record in records: doc = utils.xml_doc_to_dict(record.content) item = nd.get(record.gen_id) if item is not None: item.cover = doc.get('cover', [''])[0] return render(request, 'newinlib/frontend/list.html', { 'items_page': items_page, })
def index(request): cur_language = translation.get_language() items_page = get_page( request, ItemContent.objects.prefetch_related('item') .filter(item__publicated=True, lang=cur_language) .order_by('-item__create_date') ) nd = {} for item in items_page.object_list: nd[item.item.id_in_catalog] = item records_ids = [] for items_lis in items_page.object_list: records_ids.append(items_lis.item.id_in_catalog) records = get_records(records_ids) for record in records: doc = utils.xml_doc_to_dict(record.content) item = nd.get(record.gen_id) if item is not None: item.cover = doc.get('cover', [''])[0] return render(request, 'newinlib/frontend/list.html', { 'items_page': items_page, })
def pages_list(request, code, parent=None): if not request.user.has_module_perms("participants_pages"): return HttpResponseForbidden() library = get_object_or_404(Library, code=code) if parent: parent = get_object_or_404(Page, id=parent) pages_page = get_page(request, Page.objects.filter(parent=parent, library=library)) pages_page.object_list = list(pages_page.object_list) pages = pages_page.object_list contents = list(Content.objects.filter(page__in=pages, lang=get_language()[:2])) pages_dict = {} for page in pages: pages_dict[page.id] = {"page": page} for content in contents: pages_dict[content.page_id]["page"].content = content # pages = [page['page'] for page in pages_dict.values()] # pages = pages_page.object_list return render( request, "participants_pages/administration/pages_list.html", {"parent": parent, "pages": pages, "pages_page": pages_page, "library": library}, )
def pages_list(request, library_code, parent=None, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden( u'Вы должны быть сотрудником этой организации') if parent: parent = get_object_or_404(Page, id=parent, library=library) pages_page = get_page(request, Page.objects.filter(parent=parent, library=library)) pages_page.object_list = list(pages_page.object_list) contents = list( Content.objects.filter(page__in=pages_page.object_list, lang=get_language()[:2])) pages_dict = {} for page in pages_page.object_list: pages_dict[page.id] = {'page': page} for content in contents: pages_dict[content.page_id]['page'].content = content # pages = [page['page'] for page in pages_dict.values()] return render( request, 'participant_pages/administration/pages_list.html', { 'library': library, 'parent': parent, 'pages': pages_page.object_list, 'pages_page': pages_page, })
def events_list(request, library_code, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden( u'Вы должны быть сотрудником этой организации') if not request.user.has_module_perms('participant_events'): return HttpResponseForbidden(u'У вас нет прав для доступа к разделу') events_page = get_page( request, Event.objects.filter(library=library).order_by('-create_date'), 10) event_contents = list( EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render( request, 'participant_events/administration/events_list.html', { 'library': library, 'events_list': events_page.object_list, 'events_page': events_page, })
def filer_by_date(request, library_code, day='', month='', year=''): library = get_object_or_404(Library, code=library_code) events_page = get_page( request, models.Event.objects.filter(library=library, active=True, start_date__year=year, start_date__month=month, start_date__day=day).prefetch_related( 'age_category', 'event_type').order_by('-create_date')) event_contents = list( models.EventContent.objects.filter(event__in=list( events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content date = datetime(year=int(year), month=int(month), day=int(day)) return render( request, 'participant_events/frontend/list.html', { 'library': library, 'events_list': events_page.object_list, 'events_page': events_page, 'date': date })
def index(request, library_code): library = get_object_or_404(Library, code=library_code) events_page = get_page( request, models.Event.objects.filter(active=True, library=library).prefetch_related( 'age_category', 'event_type').order_by('-create_date')) event_contents = list( models.EventContent.objects.filter(event__in=list( events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render( request, 'participant_events/frontend/list.html', { 'library': library, 'events_list': events_page.object_list, 'events_page': events_page, })
def pages_list(request, library_code, parent=None, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden(u'Вы должны быть сотрудником этой организации') if parent: parent = get_object_or_404(Page, id=parent, library=library) pages_page = get_page(request, Page.objects.filter(parent=parent, library=library)) pages_page.object_list = list(pages_page.object_list) contents = list(Content.objects.filter(page__in=pages_page.object_list, lang=get_language()[:2])) pages_dict = {} for page in pages_page.object_list: pages_dict[page.id] = {'page': page} for content in contents: pages_dict[content.page_id]['page'].content = content # pages = [page['page'] for page in pages_dict.values()] return render(request, 'participant_pages/administration/pages_list.html', { 'library': library, 'parent': parent, 'pages': pages_page.object_list, 'pages_page': pages_page, })
def polls_list(request, library_code, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden( u'Вы должны быть сотрудником этой организации') if not request.user.has_module_perms('participant_photopolls'): return HttpResponseForbidden() polls_page = get_page( request, Poll.objects.filter(library=library).order_by('-create_date'), 10) poll_contents = list( PollContent.objects.filter(poll__in=list(polls_page.object_list), lang=get_language()[:2])) t_dict = {} for poll in polls_page.object_list: t_dict[poll.id] = {'poll': poll} for poll_content in poll_contents: t_dict[poll_content.poll_id]['poll'].poll_content = poll_content return render( request, 'participant_photopolls/administration/polls_list.html', { 'library': library, 'polls_list': polls_page.object_list, 'polls_page': polls_page, })
def index(request): news_type = request.GET.get('type', '') query = Q(publicated=True) if news_type == 'chel': query = query & Q(type=0) if news_type == 'lib': query = query & Q(type=1) news_page = get_page(request, News.objects.filter(query).order_by('-create_date')) news_contents = list(NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = { 'news': news } for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'news/frontend/list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def index(request): news_page = get_page(request, News.objects.filter(publicated=True, lang=get_language()[:2]).order_by('-order', '-create_date')) return render(request, 'news/frontend/list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def news_list(request): lang = request.GET.get('lang', 'ru') news_page = get_page(request, News.objects.filter(lang=lang).order_by('-order', '-create_date')) return render(request, 'news/administration/news_list.html', { 'news_list': news_page.object_list, 'news_page': news_page, 'langs': settings.LANGUAGES })
def district_list(request): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() districts_page = get_page(request, District.objects.all()) return render(request, 'participants/administration/district_list.html', { 'districts_page': districts_page, })
def users_list(request): users_qs = User.objects.all().exclude(id=-1).order_by('-date_joined') users_page = get_page(request, users_qs) return render(request, 'accounts/administration/user_list.html', { 'users_page': users_page, 'users': users_qs })
def district_list(request): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() districts_page = get_page(request, models.District.objects.all()) return render(request, 'participants/administration/district_list.html', { 'districts_page': districts_page, })
def id_list(request): if not request.user.has_module_perms('cid'): return HttpResponseForbidden() idates_count = ImportantDate.objects.all().count() idates_page = get_page(request, ImportantDate.objects.all().order_by('-id')) return render(request, 'cid/administration/id_list.html', { 'idates_page': idates_page, 'idates_count': idates_count })
def library_types_list(request): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() library_types_page = get_page(request, LibraryType.objects.all()) return render(request, 'participants/administration/library_types_list.html', { 'library_types_page': library_types_page, })
def library_types_list(request): if not request.user.has_module_perms("participants"): return HttpResponseForbidden() library_types_page = get_page(request, models.LibraryType.objects.all()) return render( request, "participants/administration/library_types_list.html", {"library_types_page": library_types_page} )
def feedbacks_list(request): if not request.user.has_module_perms('guestbook'): return HttpResponseForbidden() feedbacks_page = get_page(request, Feedback.objects.all().order_by('-add_date')) return render(request, 'guestbook/administration/feedbacks_list.html', { 'feedbacks_page': feedbacks_page, })
def library_types_list(request): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() library_types_page = get_page(request, models.LibraryType.objects.all()) return render(request, 'participants/administration/library_types_list.html', { 'library_types_page': library_types_page, })
def index(request, library_code): library = get_object_or_404(Library, code=library_code) lang=get_language()[:2] news_page = get_page(request, News.objects.filter(library=library, publicated=True, lang=lang).order_by('-order', '-create_date')) return render(request, 'participant_news/frontend/list.html', { 'library': library, 'news_list': news_page.object_list, 'news_page': news_page, })
def items(request): section = request.GET.get('section') q = Q() if section: q &= Q(section=section) items_page = get_page(request, Item.objects.filter(q).order_by('-created')) return render(request, 'recommended_reading/administration/items.html', { 'items_page': items_page, 'sections': ITEM_SECTIONS, 'current_section': section, })
def items(request): section = request.GET.get('section') q = Q() if section: q &= Q(section=section) items_page = get_page(request, Item.objects.filter(q).order_by('-created')) return render( request, 'recommended_reading/administration/items.html', { 'items_page': items_page, 'sections': ITEM_SECTIONS, 'current_section': section, })
def news_list(request): type = request.GET.get('type', u'public') if type == u'prof': news_page = get_page(request, News.objects.filter(type=1).order_by('-create_date')) elif type == u'public': news_page = get_page(request, News.objects.filter(type=0).order_by('-create_date')) else: news_page = get_page(request, News.objects.filter(type=2).order_by('-create_date')) news_contents = list(NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {'news': news} for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'news/administration/news_list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def index(request): news_page = get_page(request, News.objects.filter(publicated=True).exclude(type=1).order_by("-create_date")) news_contents = list(NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {"news": news} for news_content in news_contents: t_dict[news_content.news_id]["news"].news_content = news_content return render(request, "news/frontend/list.html", {"news_list": news_page.object_list, "news_page": news_page})
def index(request, section): school_class = request.GET.get('school_class') q = Q(section=section, published=True) if school_class: q &= Q(school_class=int(school_class)) items_page = get_page(request, Item.objects.filter(q).order_by('-created')) current_section = filter(lambda x: x[0] == section, ITEM_SECTIONS)[0] return render(request, 'recommended_reading/frontend/index.html', { 'items_page': items_page, 'current_section': current_section, 'school_classes': ITEM_SCHOOL_CLASSES })
def list(request, parent=None): if not request.user.has_module_perms('participants'): return HttpResponseForbidden() if parent: parent = get_object_or_404(Library, id=parent) libraries_page = get_page(request, Library.objects.filter(parent=parent)) else: if not request.user.is_superuser: cbses = [] library_content_editors = LibraryContentEditor.objects.filter(user=request.user) for lce in library_content_editors: cbses.append(lce.library_id) libraries_page = get_page(request, Library.objects.filter(id__in=cbses)) else: libraries_page = get_page(request, Library.objects.filter(parent=None)) return render(request, 'participants/administration/libraries_list.html', { 'parent': parent, 'libraries_page': libraries_page, })
def index(request, day='', month='', year=''): filter_form = forms.EventsFilterForm(request.GET, prefix='filter') q = Q(active=True) if filter_form.is_valid(): library = filter_form.cleaned_data['library'] event_type = filter_form.cleaned_data['event_type'] age_category = filter_form.cleaned_data['age_category'] if library: libs = [library.id] for item in list(library.get_children().values('id')): libs.append(item['id']) q = q & Q(library__in=libs) if event_type: q_type = Q(event_type='') for item in event_type: q = q & Q(event_type__in=event_type) q = q & q_type if age_category: q = q & Q(age_category__in=age_category) date_filtered = None if year and month and day: q = q & Q(start_date__year=year, start_date__month=month, start_date__day=day) date_filtered = datetime(year=int(year), month=int(month), day=int(day)) #print unicode(q) events_page = get_page( request, Event.objects.select_related('library').prefetch_related('age_category', 'event_type').filter(q).distinct() ) events = list(events_page.object_list) event_contents = list( EventContent.objects.filter( event__in=events, lang=get_language()[:2] )) t_dict = {} for event in events: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'events/frontend/list.html', { 'events_list': events, 'events_page': events_page, 'filter_form': filter_form, 'date_filtered': date_filtered })
def index(request, day='', month='', year=''): filter_form = forms.EventsFilterForm(request.GET, prefix='filter') q = Q(active=True) if filter_form.is_valid(): # library = filter_form.cleaned_data['library'] event_type = filter_form.cleaned_data['event_type'] age_category = filter_form.cleaned_data['age_category'] # if library: # libs = [library.id] # for item in list(library.get_children().values('id')): # libs.append(item['id']) # q = q & Q(library__in=libs) if event_type: q &= Q(event_type__in=event_type) if age_category: q &= Q(age_category__in=age_category) date_filtered = None if year and month and day: q = q & Q(start_date__year=year, start_date__month=month, start_date__day=day) date_filtered = datetime(year=int(year), month=int(month), day=int(day)) # print unicode(q) events_page = get_page( request, Event.objects.select_related('library').prefetch_related( 'age_category', 'event_type').filter(q).distinct()) events = list(events_page.object_list) event_contents = list( EventContent.objects.filter(event__in=events, lang=get_language()[:2])) t_dict = {} for event in events: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render( request, 'events/frontend/list.html', { 'events_list': events, 'events_page': events_page, 'filter_form': filter_form, 'date_filtered': date_filtered })
def news_list(request, library_code, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden(u"Вы должны быть сотрудником этой организации") if not request.user.has_module_perms("participant_news"): return HttpResponseForbidden(u"У вас нет доступа к разделу") news_page = get_page(request, News.objects.filter(library=library).order_by("-order", "-create_date")) return render( request, "participant_news/administration/news_list.html", {"library": library, "news_list": news_page.object_list, "news_page": news_page}, )
def news_list(request, library_code, managed_libraries=[]): library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden(u'Вы должны быть сотрудником этой организации') if not request.user.has_module_perms('participant_news'): return HttpResponseForbidden(u'У вас нет доступа к разделу') news_page = get_page(request, News.objects.filter(library=library).order_by('-order', '-create_date')) return render(request, 'participant_news/administration/news_list.html', { 'library': library, 'news_list': news_page.object_list, 'news_page': news_page, })
def index(request, section): school_class = request.GET.get('school_class') q = Q(section=section, published=True) if school_class: q &= Q(school_class=int(school_class)) items_page = get_page(request, Item.objects.filter(q).order_by('-created')) current_section = filter(lambda x: x[0] == section, ITEM_SECTIONS)[0] return render( request, 'recommended_reading/frontend/index.html', { 'items_page': items_page, 'current_section': current_section, 'school_classes': ITEM_SCHOOL_CLASSES })
def events_list(request): events_page = get_page(request, Event.objects.all().order_by('-create_date')) event_contents = list(EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'events/administration/events_list.html', { 'events_list': events_page.object_list, 'events_page': events_page, })
def filer_by_date(request, day='', month='', year=''): query = Q(publicated=True, create_date__year=year, create_date__month=month, create_date__day=day) news_page = get_page(request, News.objects.filter(query).exclude(type=1).order_by('-create_date')) news_contents = list(NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {'news': news} for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'news/frontend/list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def questions_list(request, my=None): manager = QuestionManager.get_manager(request.user) if not manager and not request.user.is_superuser and not request.user.has_module_perms('ask_librarian'): return HttpResponse(u'Вы не можете обрабатывать вопросы') if manager: manager.user = request.user status = request.GET.get('status', 0) if my: questions_page = get_page(request, Question.objects.filter(status=status, manager=manager).exclude(manager=None).order_by('-create_date'), 10) questions_page.object_list = list(questions_page.object_list) for question in questions_page.object_list: question.manager = manager else: questions_page = get_page(request, Question.objects.filter(status=status).order_by('-create_date'), 10) questions_page.object_list = list(questions_page.object_list) md = {} for question in questions_page.object_list: if question.manager_id: md[question.manager_id] = None managers = QuestionManager.objects.select_related('user').filter(id__in=md.keys()) for manager_item in managers: if manager_item.id in md: md[manager_item.id] = manager_item for question in questions_page.object_list: if question.manager_id: question.manager = md[question.manager_id] return render(request, 'ask_librarian/administration/questions_list.html', { 'questions_page': questions_page, })
def filer_by_date(request, day='', month='', year=''): events_page = get_page(request, Event.objects.filter(active=True, start_date__year=year, start_date__month=month, start_date__day=day).order_by('-create_date')) event_contents = list(EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'events/frontend/list.html', { 'events_list': events_page.object_list, 'events_page': events_page, })
def events_list(request): events_page = get_page(request, Event.objects.all().order_by('-create_date')) event_contents = list( EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'events/administration/events_list.html', { 'events_list': events_page.object_list, 'events_page': events_page, })
def items_list(request): items_page = get_page(request, Item.objects.all().order_by('-create_date')) items_contents = list( ItemContent.objects.filter(item__in=list(items_page.object_list), lang=get_language()[:2])) t_dict = {} for item in items_page.object_list: t_dict[item.id] = {'item': item} for item_content in items_contents: t_dict[item_content.item_id]['item'].item_content = item_content return render(request, 'newinlib/administration/items_list.html', { 'items_list': items_page.object_list, 'items_page': items_page, })
def news_list(request): news_page = get_page(request, News.objects.all().order_by('-create_date')) news_contents = list( NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {'news': news} for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'professionals_news/administration/news_list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def favorit_events(request, library_code): fav_events_page = get_page(request, models.FavoriteEvent.objects.filter(user=request.user)) events = [] for fav_event in fav_events_page.object_list: events.append(fav_event.event_id) events = models.Event.objects.filter(id__in=events) event_contents = list(models.EventContent.objects.filter(event__in=list(events), lang=get_language()[:2])) t_dict = {} for event in events: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'participant_events/frontend/favorites_list.html', { 'events_list': events, 'events_page': fav_events_page, })
def index(request): filter_form = forms.NewsFilter(request.GET) lang = get_language()[:2] q = Q(publicated=True, lang=lang) if filter_form.is_valid(): library = filter_form.cleaned_data['library'] if library: libs = [library.id] for item in list(library.get_children().values('id')): libs.append(item['id']) q = q & Q(library__in=libs) news_page = get_page( request, News.objects.select_related('library').filter(q).order_by( '-create_date')) return render( request, 'participant_news/all_frontend/list.html', { 'news_list': news_page.object_list, 'news_page': news_page, 'filter_form': filter_form })
def index(request): feedbacks_page = get_page( request, Feedback.objects.filter(publicated=True).order_by('-add_date')) count_feedback = len(feedbacks_page) if request.method == 'POST': form = FeedbackForm(request.POST) if form.is_valid(): form.save() return render(request, 'guestbook/frontend/thanks.html') else: form = FeedbackForm() return render( request, 'guestbook/frontend/index.html', { 'feedbacks_page': feedbacks_page, 'form': form, 'count_feedback': count_feedback })
def filer_by_date(request, day='', month='', year=''): events_page = get_page( request, Event.objects.filter(active=True, start_date__year=year, start_date__month=month, start_date__day=day).order_by('-create_date')) event_contents = list( EventContent.objects.filter(event__in=list(events_page.object_list), lang=get_language()[:2])) t_dict = {} for event in events_page.object_list: t_dict[event.id] = {'event': event} for event_content in event_contents: t_dict[event_content.event_id]['event'].event_content = event_content return render(request, 'events/frontend/list.html', { 'events_list': events_page.object_list, 'events_page': events_page, })
def index(request): news_page = get_page( request, News.objects.filter(publicated=True).exclude( type=1).order_by('-create_date')) news_contents = list( NewsContent.objects.filter(news__in=list(news_page.object_list), lang=get_language()[:2])) t_dict = {} for news in news_page.object_list: t_dict[news.id] = {'news': news} for news_content in news_contents: t_dict[news_content.news_id]['news'].news_content = news_content return render(request, 'news/frontend/list.html', { 'news_list': news_page.object_list, 'news_page': news_page, })
def menu_list(request): if not request.user.has_module_perms('menu'): return HttpResponseForbidden() menus_page = get_page(request, Menu.objects.all()) menu_titles = list( MenuTitle.objects.filter(menu__in=list(menus_page.object_list), lang=get_language()[:2])) menus_dict = {} for menu in menus_page.object_list: menus_dict[menu.id] = {'menu': menu} for menu_title in menu_titles: menus_dict[menu_title.menu_id]['menu'].menu_title = menu_title menus = [menu['menu'] for menu in menus_dict.values()] return render(request, 'menu/administration/menus_list.html', { 'menus': menus, 'menus_page': menus_page, })
def index(request, library_code, lang='ru', managed_libraries=[]): now = datetime.now() library = org_utils.get_library(library_code, managed_libraries) if not library: return HttpResponseForbidden( u'Вы должны быть сотрудником этой организации') if not request.user.has_module_perms('participant_banners'): return HttpResponseForbidden(u'У вас нет прав для доступа к разделу') banners_page = get_page( request, models.Banner.objects.filter(library_creator=library.id, lang=lang)) return render( request, 'participant_banners/administration/index.html', { 'banners_page': banners_page, 'library': library, 'languages': settings.LANGUAGES, 'current_lang': lang, 'now': now })