def attachment(request, object_id, update_id=None): dajax = Dajax() try: if object_id: attachments = Attachment.objects.filter( attached_object__id=object_id) template = 'core/tags/attachments_block' object_markup = render_to_string(template, {'object_id': object_id, 'attachments': attachments}, context_instance=RequestContext( request), response_format='html') dajax.add_data( {'target': 'div.attachment-block[object="%s"]' % object_id, 'content': object_markup}, 'treeio.add_data') if update_id: attachments = Attachment.objects.filter( attached_record__id=update_id) template = 'core/tags/attachments_record_block' update_markup = render_to_string(template, {'update_id': update_id, 'attachments': attachments}, context_instance=RequestContext( request), response_format='html') dajax.add_data( {'target': 'div.attachment-record-block[object="%s"]' % update_id, 'content': update_markup}, 'treeio.add_data') except Exception, e: print e
def permission_block(context, object): "Block with objects permissions" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] response_format_tags = response_format if 'response_format_tags' in context: response_format_tags = context['response_format_tags'] if 'permission' in request.GET: if request.user.get_profile().has_permission(object, mode='w'): if request.POST: if 'cancel' in request.POST: request.redirect = request.path return Markup(render_to_string('core/tags/permission_block', {'object': object, 'path': request.path}, context_instance=RequestContext( request), response_format=response_format)) form = PermissionForm(request.POST, instance=object) if form.is_valid(): form.save() request.redirect = request.path return Markup(render_to_string('core/tags/permission_block', {'object': object, 'path': request.path}, context_instance=RequestContext( request), response_format=response_format)) else: form = PermissionForm(instance=object) context = {'object': object, 'path': request.path, 'form': form} if 'ajax' in response_format_tags: context = converter.preprocess_context(context) return Markup(render_to_string('core/tags/permission_block_edit', context, context_instance=RequestContext( request), response_format=response_format)) return Markup(render_to_string('core/tags/permission_block', {'object': object, 'path': request.path}, context_instance=RequestContext(request), response_format=response_format))
def messaging_unread(context): "Print a number of unread messages" request = context['request'] user = None if request.user.username: try: user = request.user.get_profile() except Exception: pass unread = 0 messaging = None if user: modules = user.get_perspective().get_modules() messaging = modules.filter(name='treeio.messaging') if messaging: unread = Object.filter_permitted(user, Message.objects.filter(reply_to__isnull=True).exclude(read_by=user)).count() response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('messaging/tags/unread', {'messaging': messaging, 'unread': unread}, context_instance=RequestContext(request), response_format=response_format))
def core_watchlist(context, objects=None, skip_group=False, paginate=False): "Print a list of objects a user is subscribed to" request = context['request'] profile = request.user.get_profile() if not objects: objects = profile.subscriptions.all() if 'unsubscribe' in request.GET: for object in objects.filter(pk=request.GET.get('unsubscribe')): object.subscribers.remove(profile) objects = profile.subscriptions.all() pathurl = request.path + '?' if request.GET: params = request.GET.copy() if 'unsubscribe' in params: del params['unsubscribe'] pathurl += urllib.urlencode(params) + '&' response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('core/tags/watchlist', {'objects': objects, 'skip_group': skip_group, 'dopaginate': paginate, 'pathurl': pathurl}, context_instance=RequestContext(request), response_format=response_format))
def icon_line(context, user=None, size=25): """ Print a line with a certain amount off achievement-icons. Arguments: context -- the current Context object, supplied by the decorator user -- which user, defaults to the active account size -- how many icons should be displayed """ request = context["request"] if not user: user = request.user response_format = "html" if "response_format" in context: response_format = context["response_format"] achievements = user.achievements.all()[:size] return Markup( render_to_string( "achievements/tags/icon_line", {"achievements": achievements}, context_instance=RequestContext(request), response_format=response_format, ) )
def attachments(context, object=None): "Attachments for an object or update record" request = context['request'] profile = request.user.get_profile() response_format = 'html' if 'response_format' in context: response_format = context['response_format'] update = isinstance(object,UpdateRecord) if not update: attachments = Attachment.objects.filter(attached_object=object) if profile.has_permission(object, mode='w'): template = 'core/tags/attachments' else: template = 'core/tags/attachments_block' else: attachments = Attachment.objects.filter(attached_record=object) if profile == object.author: template = 'core/tags/attachments_record' else: template = 'core/tags/attachments_record_block' return Markup(render_to_string(template, {'object': object, 'attachments': attachments, }, context_instance=RequestContext(request), response_format=response_format))
def user_block(context): "User block" request = context['request'] user = None if request.user.username: try: user = request.user.get_profile() except Exception: pass modules = user.get_perspective().get_modules() account = modules.filter(name='treeio.account') admin = modules.filter(name='treeio.core') if admin: admin = admin[0] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] trial = False if getattr(settings, 'HARDTREE_SUBSCRIPTION_USER_LIMIT') == 3: trial = True active = context.get('active', None) return Markup(render_to_string('core/tags/user_block', {'user': user, 'account': account, 'admin': admin, 'active': active, 'trial': trial}, response_format=response_format))
def logo_block_container(context): "Returns logo_block_container" # request = context['request'] response_format = "html" return Markup(render_to_string("core/tags/logo_block_container", response_format=response_format))
def email_caller_on_new_ticket(sender, instance, created, **kwargs): "When a new ticket is created send an email to the caller" if created: send_email_to_caller = False try: conf = ModuleSetting.get_for_module("treeio.services", "send_email_to_caller")[0] send_email_to_caller = conf.value except: send_email_to_caller = getattr(settings, "HARDTREE_SEND_EMAIL_TO_CALLER", True) if send_email_to_caller: # don't send email to yourself creator_contact = None if instance.creator: creator_contact = instance.creator.get_contact() if instance.caller and instance.caller != creator_contact: if not instance.reference: if instance.queue: instance.reference = instance.queue.ticket_code + str(instance.id) else: instance.reference = str(instance.id) instance.save() subject = "[#%s] %s" % (instance.reference, instance.name) # Construct context and render to html, body context = {"ticket": instance} try: conf = ModuleSetting.get_for_module("treeio.services", "send_email_template")[0] send_email_template = conf.value html = render_string_template(send_email_template, context) except Exception, e: html = render_to_string("services/emails/notify_caller", context, response_format="html") body = strip_tags(html) if instance.queue and instance.queue.message_stream: stream = instance.queue.message_stream if stream.outgoing_server_name: try: caller_email = instance.caller.get_email() if caller_email: toaddr = caller_email ssl = False if stream.outgoing_server_type == "SMTP-SSL": ssl = True email = BaseEmail( stream.outgoing_server_name, stream.outgoing_server_username, stream.outgoing_password, stream.outgoing_email, toaddr, subject, body, html=html, ssl=ssl, ) email.process_email() except: pass
def logo_block_container(context): "Returns logo_block_container" #request = context['request'] response_format = 'html' return Markup( render_to_string('core/tags/logo_block_container', response_format=response_format))
def tags_box(context, object): request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] response_format_tags = response_format if 'response_format_tags' in context: response_format_tags = context['response_format_tags'] tags = object.tags.all() form = None if 'tags-edit' in request.GET: if request.POST.get('tags_object', 0) == unicode(object.id): form = TagsForm(tags, request.POST) if form.is_valid(): if 'multicomplete_tags' in request.POST: tag_names = request.POST.get('multicomplete_tags').split( ',') new_tags = [] for name in tag_names: name = name.strip() if name: try: tag = Tag.objects.get(name=name) except Tag.DoesNotExist: tag = Tag(name=name) tag.save() new_tags.append(tag) else: new_tags = form.is_valid() object.tags.clear() for tag in new_tags: object.tags.add(tag) tags = object.tags.all() form = None else: form = TagsForm(tags) context = { 'object': object, 'tags': tags, 'form': form, 'editlink': request.path + '?tags-edit' } if 'ajax' in response_format_tags: context = converter.preprocess_context(context) return Markup( render_to_string('core/tags/tags_box', context, context_instance=RequestContext(request), response_format=response_format))
def attachment(request, object_id, update_id=None): dajax = Dajax() try: if object_id: attachments = Attachment.objects.filter( attached_object__id=object_id) template = 'core/tags/attachments_block' object_markup = render_to_string( template, { 'object_id': object_id, 'attachments': attachments }, context_instance=RequestContext(request), response_format='html') dajax.add_data( { 'target': 'div.attachment-block[object="%s"]' % object_id, 'content': object_markup }, 'treeio.add_data') if update_id: attachments = Attachment.objects.filter( attached_record__id=update_id) template = 'core/tags/attachments_record_block' update_markup = render_to_string( template, { 'update_id': update_id, 'attachments': attachments }, context_instance=RequestContext(request), response_format='html') dajax.add_data( { 'target': 'div.attachment-record-block[object="%s"]' % update_id, 'content': update_markup }, 'treeio.add_data') except Exception, e: print e
def demo_user(context): "Print demo block if demo" response_format = 'html' demo = getattr(settings, 'HARDTREE_DEMO_MODE', False) return Markup(render_to_string('core/tags/demo_user', {'demo': demo}, response_format=response_format))
def demo_user(context): "Print demo block if demo" response_format = 'html' demo = getattr(settings, 'HARDTREE_DEMO_MODE', False) return Markup(render_to_string('core/tags/demo_user', {'demo': demo}, response_format=response_format))
def email_caller_on_new_ticket(sender, instance, created, **kwargs): "When a new ticket is created send an email to the caller" if created: send_email_to_caller = False try: conf = ModuleSetting.get_for_module('treeio.services', 'send_email_to_caller')[0] send_email_to_caller = conf.value except: send_email_to_caller = getattr(settings, 'HARDTREE_SEND_EMAIL_TO_CALLER', True) if send_email_to_caller: # don't send email to yourself creator_contact = None if instance.creator: creator_contact = instance.creator.get_contact() if instance.caller and instance.caller != creator_contact: if not instance.reference: if instance.queue: instance.reference = instance.queue.ticket_code + str(instance.id) else: instance.reference = str(instance.id) instance.save() subject = "[#%s] %s" % (instance.reference, instance.name) # Construct context and render to html, body context = {'ticket': instance} try: conf = ModuleSetting.get_for_module('treeio.services', 'send_email_template')[0] send_email_template = conf.value html = render_string_template(send_email_template, context) except Exception, e: html = render_to_string('services/emails/notify_caller', context, response_format='html') body = strip_tags(html) if instance.queue and instance.queue.message_stream: stream = instance.queue.message_stream if stream.outgoing_server_name: try: caller_email = instance.caller.get_email() if caller_email: toaddr = caller_email ssl = False if stream.outgoing_server_type == 'SMTP-SSL': ssl = True email = BaseEmail(stream.outgoing_server_name, stream.outgoing_server_username, stream.outgoing_password, stream.outgoing_email, toaddr, subject, body, html=html, ssl=ssl) email.process_email() except: pass
def object_tree_path(context, object, skipself=False): "Object tree path" response_format = 'html' if 'response_format' in context: response_format = context['response_format'] path = object.get_tree_path(skipself) return Markup(render_to_string('core/tags/object_tree_path', {'path': path, 'skipself': skipself}, response_format=response_format))
def object_tree_path(context, object, skipself=False): "Object tree path" response_format = 'html' if 'response_format' in context: response_format = context['response_format'] path = object.get_tree_path(skipself) return Markup(render_to_string('core/tags/object_tree_path', {'path': path, 'skipself': skipself}, response_format=response_format))
def knowledge_item_list(context, items, skip_group=False): "Print a list of items" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('knowledge/tags/item_list', {'items': items, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def changes_set_list(context, changesets): "Print a list of ChangeSets" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('changes/tags/changeset_list', {'changesets': changesets}, context_instance=RequestContext(request), response_format=response_format))
def finance_transaction_list(context, transactions, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('finance/tags/transaction_list', {'transactions': transactions, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def finance_liability_list(context, liabilities, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('finance/tags/liability_list', {'liabilities': liabilities, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def tags_box(context, object): request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] response_format_tags = response_format if 'response_format_tags' in context: response_format_tags = context['response_format_tags'] tags = object.tags.all() form = None if 'tags-edit' in request.GET: if request.POST.get('tags_object', 0) == unicode(object.id): form = TagsForm(tags, request.POST) if form.is_valid(): if 'multicomplete_tags' in request.POST: tag_names = request.POST.get( 'multicomplete_tags').split(',') new_tags = [] for name in tag_names: name = name.strip() if name: try: tag = Tag.objects.get(name=name) except Tag.DoesNotExist: tag = Tag(name=name) tag.save() new_tags.append(tag) else: new_tags = form.is_valid() object.tags.clear() for tag in new_tags: object.tags.add(tag) tags = object.tags.all() form = None else: form = TagsForm(tags) context = {'object': object, 'tags': tags, 'form': form, 'editlink': request.path + '?tags-edit'} if 'ajax' in response_format_tags: context = converter.preprocess_context(context) return Markup(render_to_string('core/tags/tags_box', context, context_instance=RequestContext(request), response_format=response_format))
def infrastructure_servicing_list(context, items, skip_group=False): "Print a list of tasks" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('infrastructure/tags/servicing_list', {'service_records': items, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def events_event_list(context, events): "Print a list of events" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('events/tags/event_list', {'events': events}, context_instance=RequestContext(request), response_format=response_format))
def administration_module_list(context, modules): "Print a list of users" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('core/administration/tags/module_list', {'modules': modules}, context_instance=RequestContext(request), response_format=response_format))
def administration_user_list(context, users, skip_group=False): "Print a list of users" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('core/administration/tags/user_list', {'users': users, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def changes_set_list(context, changesets): "Print a list of ChangeSets" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('changes/tags/changeset_list', {'changesets': changesets}, context_instance=RequestContext(request), response_format=response_format))
def identities_group_list(context, groups, skip_group=False): "Print a list of groups" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('identities/tags/group_list', {'groups': groups, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def sales_opportunity_list(context, opportunities, skip_group=False): "Print a list of opportunitys" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('sales/tags/opportunity_list', {'opportunities': opportunities, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def services_queue_list(context, queues, skip_group=False): "Print a list of queues" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('services/tags/queue_list', {'queues': queues, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def projects_time_slot_list(context, time_slots, no_dates=False): "Print a list of time slots" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('projects/tags/time_slot_list', {'time_slots': time_slots, 'no_dates': no_dates}, context_instance=RequestContext(request), response_format=response_format))
def events_event_list(context, events): "Print a list of events" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('events/tags/event_list', {'events': events}, context_instance=RequestContext(request), response_format=response_format))
def news_update_list(context, updates, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('news/tags/update_list', {'updates': updates}, context_instance=RequestContext(request), response_format=response_format))
def sales_lead_list(context, leads, skip_group=False): "Print a list of leads" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('sales/tags/lead_list', {'leads': leads, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def news_update_list(context, updates, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('news/tags/update_list', {'updates': updates}, context_instance=RequestContext(request), response_format=response_format))
def documents_objects_list(context, objects, folder, skip_group=False): "Print a list of all objects" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('documents/tags/objects_list', {'objects': objects, 'skip_group': skip_group, 'folder':folder}, context_instance=RequestContext(request), response_format=response_format))
def documents_weblink_list(context, links, skip_group=False): "Print a list of links" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('documents/tags/weblink_list', {'links': links, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def object_tree_path(context, object, skipself=False): "Object tree path" response_format = "html" if "response_format" in context: response_format = context["response_format"] path = object.get_tree_path(skipself) return Markup( render_to_string( "core/tags/object_tree_path", {"path": path, "skipself": skipself}, response_format=response_format ) )
def administration_module_list(context, modules): "Print a list of users" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('core/administration/tags/module_list', {'modules': modules}, context_instance=RequestContext(request), response_format=response_format))
def projects_time_slot_list(context, time_slots, no_dates=False): "Print a list of time slots" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('projects/tags/time_slot_list', {'time_slots': time_slots, 'no_dates': no_dates}, context_instance=RequestContext(request), response_format=response_format))
def sales_opportunity_list(context, opportunities, skip_group=False): "Print a list of opportunitys" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('sales/tags/opportunity_list', {'opportunities': opportunities, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def notification_setting_list(context, notification_settings, skip_group=False): "Print a list of settings" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('account/tags/notification_setting_list', {'settings': notification_settings, 'skip_group': skip_group}, context_instance=RequestContext(request), response_format=response_format))
def easy_invite_block(context, emails=[]): "The humanized datetime of the last update to an object" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('core/tags/easy_invite', {'emails': emails,}, context_instance=RequestContext(request), response_format=response_format))
def tags(request, target, object_id, edit=False, formdata={}): dajax = Dajax() response_format = 'html' object = Object.objects.get(pk=object_id) tags = object.tags.all() form = None if 'tags' in formdata and not type(formdata['tags']) == list: formdata['tags'] = [formdata['tags']] if edit or formdata: if formdata.get('tags_object', 0) == unicode(object.id): form = TagsForm(tags, formdata) if form.is_valid(): if 'multicomplete_tags' in formdata: tag_names = formdata.get('multicomplete_tags').split(',') new_tags = [] for name in tag_names: name = name.strip() if name: try: tag = Tag.objects.get(name=name) except Tag.DoesNotExist: tag = Tag(name=name) tag.save() new_tags.append(tag) else: new_tags = form.is_valid() object.tags.clear() for tag in new_tags: object.tags.add(tag) tags = object.tags.all() form = None else: form = TagsForm(tags) context = {'object': object, 'tags': tags, 'form': form} context = converter.preprocess_context(context) output = render_to_string('core/ajax/tags_box', context, context_instance=RequestContext(request), response_format=response_format) dajax.add_data({'target': target, 'content': output}, 'treeio.add_data') return dajax.json()
def documents_weblink_list(context, links, skip_group=False): "Print a list of links" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('documents/tags/weblink_list', { 'links': links, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def infrastructure_servicing_list(context, items, skip_group=False): "Print a list of tasks" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('infrastructure/tags/servicing_list', { 'service_records': items, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def administration_user_list(context, users, skip_group=False): "Print a list of users" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('core/administration/tags/user_list', { 'users': users, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def identities_contact_list(context, contacts, skip_group=''): "Print a list of contacts" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] contact_fields = ContactField.objects.all().filter(trash=False) return Markup(render_to_string('identities/tags/contact_list', {'contacts': contacts, 'skip_group': skip_group, 'contact_fields': contact_fields}, context_instance=RequestContext(request), response_format=response_format))
def knowledge_folder_list(context, subfolders, skip_group=False): "Print a list of types" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('knowledge/tags/folder_list', { 'subfolders': subfolders, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def show_hint(context, hint=None, object=None): "Generic hint framework" request = context['request'] response_format = 'html' user = None if request.user.username: try: user = request.user.get_profile() except Exception: pass return Markup(render_to_string('core/hints/' + hint, {'user': user, 'object': object}, response_format=response_format))
def easy_invite_block(context, emails=[]): "The humanized datetime of the last update to an object" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('core/tags/easy_invite', { 'emails': emails, }, context_instance=RequestContext(request), response_format=response_format))
def finance_liability_list(context, liabilities, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('finance/tags/liability_list', { 'liabilities': liabilities, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def finance_transaction_list(context, transactions, skip_group=False): "Print a list of orders" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('finance/tags/transaction_list', { 'transactions': transactions, 'skip_group': skip_group }, context_instance=RequestContext(request), response_format=response_format))
def documents_objects_list(context, objects, folder, skip_group=False): "Print a list of all objects" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup( render_to_string('documents/tags/objects_list', { 'objects': objects, 'skip_group': skip_group, 'folder': folder }, context_instance=RequestContext(request), response_format=response_format))
def modules_header_block(context): "Modules header block" request = context['request'] modules, active = _get_modules(request) for module in modules: module.title = _(module.title) response_format = 'html' if 'response_format' in context: response_format = context['response_format'] return Markup(render_to_string('core/tags/modules_header_block', {'modules': modules, 'active': active, 'request': request}, response_format=response_format))
def get_more(request, target='#more-news', skip=20): dajax = Dajax() profile = request.user.get_profile() query = _get_filter_query(profile) & ( ~Q(author=profile) | Q(record_type='share') | Q(score__gt=0)) updates = UpdateRecord.objects.filter(query).distinct()[skip:skip + 20] output = render_to_string('news/ajax/index', { 'updates': updates, 'skip': skip + 20 }, context_instance=RequestContext(request), response_format='html') dajax.add_data({'target': target, 'content': output}, 'treeio.add_data') return dajax.json()
def last_updated(context, object=None, verbose=False): "The humanized datetime of the last update to an object" request = context['request'] response_format = 'html' if 'response_format' in context: response_format = context['response_format'] updated = object.last_updated return Markup( render_to_string('core/tags/last_updated', { 'updated': updated, 'verbose': verbose }, context_instance=RequestContext(request), response_format=response_format))