desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Convert to HTML the content if the MARKUP_LANGUAGE
is set to HTML to optimize the rendering and avoid
ugly effect in WYMEditor.'
| def htmlize(self, content):
| if (MARKUP_LANGUAGE == 'html'):
return linebreaks(content)
return content
|
'Decorate the view dispatcher with csrf_exempt.'
| @method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs):
| return super(EntryTrackback, self).dispatch(*args, **kwargs)
|
'Retrieve the Entry trackbacked.'
| def get_object(self):
| return get_object_or_404(Entry.published, pk=self.kwargs['pk'])
|
'GET only do a permanent redirection to the Entry.'
| def get(self, request, *args, **kwargs):
| entry = self.get_object()
return HttpResponsePermanentRedirect(entry.get_absolute_url())
|
'Check if an URL is provided and if trackbacks
are enabled on the Entry.
If so the URL is registered one time as a trackback.'
| def post(self, request, *args, **kwargs):
| url = request.POST.get('url')
if (not url):
return self.get(request, *args, **kwargs)
entry = self.get_object()
site = Site.objects.get_current()
if (not entry.trackbacks_are_open):
return self.render_to_response({'error': ('Trackback is not enabled for %s' % entry.tit... |
'Get entry corresponding to \'pk\' encoded in base36
in the \'token\' variable and return the get_absolute_url
of the entry.'
| def get_redirect_url(self, **kwargs):
| entry = get_object_or_404(Entry.published, pk=int(kwargs['token'], 36))
return entry.get_absolute_url()
|
'Overridde the get_queryset method to
do some validations and build the search queryset.'
| def get_queryset(self):
| entries = Entry.published.none()
if self.request.GET:
self.pattern = self.request.GET.get('pattern', '')
if (len(self.pattern) < 3):
self.error = _('The pattern is too short')
else:
entries = Entry.published.search(self.pattern)
else:
self.... |
'Add error and pattern in context.'
| def get_context_data(self, **kwargs):
| context = super(BaseEntrySearch, self).get_context_data(**kwargs)
context.update({'error': self.error, 'pattern': self.pattern})
return context
|
'Override the get_queryset method to build
the queryset with entry matching query.'
| def get_queryset(self):
| return Entry.published.search(self.query)
|
'Add query in context.'
| def get_context_data(self, **kwargs):
| context = super(BaseEntryChannel, self).get_context_data(**kwargs)
context.update({'query': self.query})
return context
|
'Populate the context of the template
with technical informations for building urls.'
| def get_context_data(self, **kwargs):
| context = super(CapabilityView, self).get_context_data(**kwargs)
context.update({'protocol': PROTOCOL, 'copyright': COPYRIGHT, 'feeds_format': FEEDS_FORMAT, 'site': Site.objects.get_current()})
return context
|
'Override get_dated_items to add a useful \'week_end_day\'
variable in the extra context of the view.'
| def get_dated_items(self):
| (self.date_list, self.object_list, extra_context) = super(EntryWeek, self).get_dated_items()
self.date_list = self.get_date_list(self.object_list, 'day')
extra_context['week_end_day'] = (extra_context['week'] + datetime.timedelta(days=6))
return (self.date_list, self.object_list, extra_context)
|
'Return (date_list, items, extra_context) for this request.
And defines self.year/month/day for
EntryQuerysetArchiveTemplateResponseMixin.'
| def get_dated_items(self):
| now = timezone.now()
if timezone.is_aware(now):
now = timezone.localtime(now)
today = now.date()
(self.year, self.month, self.day) = today.isoformat().split('-')
return self._get_dated_items(today)
|
'Return the login view.'
| def login(self):
| return login(self.request, 'zinnia/login.html')
|
'Return the password view.'
| def password(self):
| return self.response_class(request=self.request, template='zinnia/password.html', context={'error': self.error})
|
'Do the login and password protection.'
| def get(self, request, *args, **kwargs):
| response = super(EntryProtectionMixin, self).get(request, *args, **kwargs)
if (self.object.login_required and (not request.user.is_authenticated)):
return self.login()
if (self.object.password and (self.object.password != self.request.session.get((self.session_key % self.object.pk)))):
retur... |
'Do the login and password protection.'
| def post(self, request, *args, **kwargs):
| self.object = self.get_object()
self.login()
if self.object.password:
entry_password = self.request.POST.get('entry_password')
if entry_password:
if (entry_password == self.object.password):
self.request.session[(self.session_key % self.object.pk)] = self.object.p... |
'Returns a dict of the next and previous date periods
with published entries.'
| def get_previous_next_published(self, date):
| previous_next = getattr(self, 'previous_next', None)
if (previous_next is None):
date_year = datetime(date.year, 1, 1)
date_month = datetime(date.year, date.month, 1)
date_day = datetime(date.year, date.month, date.day)
date_next_week = (date_day + timedelta(weeks=1))
pre... |
'Get the next year with published entries.'
| def get_next_year(self, date):
| return self.get_previous_next_published(date)['year'][1]
|
'Get the previous year with published entries.'
| def get_previous_year(self, date):
| return self.get_previous_next_published(date)['year'][0]
|
'Get the next week with published entries.'
| def get_next_week(self, date):
| return self.get_previous_next_published(date)['week'][1]
|
'Get the previous wek with published entries.'
| def get_previous_week(self, date):
| return self.get_previous_next_published(date)['week'][0]
|
'Get the next month with published entries.'
| def get_next_month(self, date):
| return self.get_previous_next_published(date)['month'][1]
|
'Get the previous month with published entries.'
| def get_previous_month(self, date):
| return self.get_previous_next_published(date)['month'][0]
|
'Get the next day with published entries.'
| def get_next_day(self, date):
| return self.get_previous_next_published(date)['day'][1]
|
'Get the previous day with published entries.'
| def get_previous_day(self, date):
| return self.get_previous_next_published(date)['day'][0]
|
'Check if relation_names is correctly set and
do a prefetch related on the queryset with it.'
| def get_queryset(self):
| if (self.relation_names is None):
raise ImproperlyConfigured(("'%s' must define 'relation_names'" % self.__class__.__name__))
if (not isinstance(self.relation_names, (tuple, list))):
raise ImproperlyConfigured(("%s's relation_names property must be a tuple or lis... |
'If the status of the entry is not PUBLISHED,
a preview is requested, so we check if the user
has the \'zinnia.can_view_all\' permission or if
it\'s an author of the entry.'
| def get_object(self, queryset=None):
| obj = super(EntryPreviewMixin, self).get_object(queryset)
if obj.is_visible:
return obj
if (self.request.user.has_perm('zinnia.can_view_all') or (self.request.user.pk in [author.pk for author in obj.authors.all()])):
return obj
raise Http404(_('No entry found matching the ... |
'Implement cache on ``get_object`` method to
avoid repetitive calls, in POST.'
| def get_object(self, queryset=None):
| if (self._cached_object is None):
self._cached_object = super(EntryCacheMixin, self).get_object(queryset)
return self._cached_object
|
'Return the model type for templates.'
| def get_model_type(self):
| if (self.model_type is None):
raise ImproperlyConfigured(("%s requires either a definition of 'model_type' or an implementation of 'get_model_type()'" % self.__class__.__name__))
return self.model_type
|
'Return the model name for templates.'
| def get_model_name(self):
| if (self.model_name is None):
raise ImproperlyConfigured(("%s requires either a definition of 'model_name' or an implementation of 'get_model_name()'" % self.__class__.__name__))
return self.model_name
|
'Return a list of template names to be used for the view.'
| def get_template_names(self):
| model_type = self.get_model_type()
model_name = self.get_model_name()
templates = [('zinnia/%s/%s/entry_list.html' % (model_type, model_name)), ('zinnia/%s/%s_entry_list.html' % (model_type, model_name)), ('zinnia/%s/entry_list.html' % model_type), 'zinnia/entry_list.html']
if (self.template_name is not... |
'Method for accessing to the value of
self.get_year(), self.get_month(), etc methods
if they exists.'
| def get_archive_part_value(self, part):
| try:
return getattr(self, ('get_%s' % part))()
except AttributeError:
return None
|
'Return a list of default base templates used
to build the full list of templates.'
| def get_default_base_template_names(self):
| return [('entry%s.html' % self.template_name_suffix)]
|
'Return a list of template names to be used for the view.'
| def get_template_names(self):
| year = self.get_archive_part_value('year')
week = self.get_archive_part_value('week')
month = self.get_archive_part_value('month')
day = self.get_archive_part_value('day')
templates = []
path = 'zinnia/archives'
template_names = self.get_default_base_template_names()
for template_name in... |
'Return archive part for today'
| def get_archive_part_value(self, part):
| parts_dict = {'year': '%Y', 'month': self.month_format, 'week': self.week_format, 'day': '%d'}
if (self.today is None):
today = timezone.now()
if timezone.is_aware(today):
today = timezone.localtime(today)
self.today = today
return self.today.strftime(parts_dict[part])
|
'Return the Entry.template value.'
| def get_default_base_template_names(self):
| return [self.object.detail_template, ('%s.html' % self.object.slug), ('%s_%s' % (self.object.slug, self.object.detail_template))]
|
'Check that the queryset is defined and call it.'
| def get_queryset(self):
| if (self.queryset is None):
raise ImproperlyConfigured(("'%s' must define 'queryset'" % self.__class__.__name__))
return self.queryset()
|
'Populate the context of the template
with all published entries and all the categories.'
| def get_context_data(self, **kwargs):
| context = super(Sitemap, self).get_context_data(**kwargs)
context.update({'entries': Entry.published.all(), 'categories': Category.published.all(), 'authors': Author.published.all()})
return context
|
'Return a queryset of published authors,
with a count of their entries published.'
| def get_queryset(self):
| return Author.published.all().annotate(count_entries_published=Count('entries'))
|
'Retrieve the author by his username and
build a queryset of his published entries.'
| def get_queryset(self):
| self.author = get_object_or_404(Author, **{Author.USERNAME_FIELD: self.kwargs['username']})
return self.author.entries_published()
|
'Add the current author in context.'
| def get_context_data(self, **kwargs):
| context = super(BaseAuthorDetail, self).get_context_data(**kwargs)
context['author'] = self.author
return context
|
'The model name is the author\'s username.'
| def get_model_name(self):
| return self.author.get_username()
|
'Return a queryset of published tags,
with a count of their entries published.'
| def get_queryset(self):
| return Tag.objects.usage_for_queryset(Entry.published.all(), counts=True)
|
'Retrieve the tag by his name and
build a queryset of his published entries.'
| def get_queryset(self):
| self.tag = get_tag(self.kwargs['tag'])
if (self.tag is None):
raise Http404((_('No Tag found matching "%s".') % self.kwargs['tag']))
return TaggedItem.objects.get_by_model(Entry.published.all(), self.tag)
|
'Add the current tag in context.'
| def get_context_data(self, **kwargs):
| context = super(BaseTagDetail, self).get_context_data(**kwargs)
context['tag'] = self.tag
return context
|
'The model name is the tag slugified.'
| def get_model_name(self):
| return slugify(self.tag)
|
'Get entry corresponding to \'pk\' and
return the get_absolute_url of the entry.'
| def get_redirect_url(self, **kwargs):
| entry = Entry.published.all().order_by('?')[0]
return entry.get_absolute_url()
|
'Overloads the choice method to add the position
of the object in the tree for future sorting.'
| def choice(self, obj):
| tree_id = getattr(obj, self.queryset.model._mptt_meta.tree_id_attr, 0)
left = getattr(obj, self.queryset.model._mptt_meta.left_attr, 0)
return (super(MPTTModelChoiceIterator, self).choice(obj) + ((tree_id, left),))
|
'Create labels which represent the tree level of each node
when generating option labels.'
| def label_from_instance(self, obj):
| label = smart_text(obj)
prefix = (self.level_indicator * getattr(obj, obj._mptt_meta.level_attr))
if prefix:
return ('%s %s' % (prefix, label))
return label
|
'Override the _get_choices method to use MPTTModelChoiceIterator.'
| def _get_choices(self):
| return MPTTModelChoiceIterator(self)
|
'Initializes the widget directly not stacked.'
| def __init__(self, verbose_name, is_stacked=False, attrs=None, choices=()):
| super(MPTTFilteredSelectMultiple, self).__init__(verbose_name, is_stacked, attrs, choices)
|
'Overrides the render_option method to handle
the sort_fields argument.'
| def render_option(self, selected_choices, option_value, option_label, sort_fields):
| option_value = force_text(option_value)
option_label = escape(force_text(option_label))
if (option_value in selected_choices):
selected_html = mark_safe(' selected="selected"')
else:
selected_html = ''
return format_html(six.text_type('<option value="{1}"{2} data-tree-id="{3... |
'This is copy\'n\'pasted from django.forms.widgets Select(Widget)
change to the for loop and render_option so they will unpack
and use our extra tuple of mptt sort fields (if you pass in
some default choices for this field, make sure they have the
extra tuple too!).'
| def render_options(self, selected_choices):
| selected_choices = set((force_text(v) for v in selected_choices))
output = []
for (option_value, option_label, sort_fields) in self.choices:
output.append(self.render_option(selected_choices, option_value, option_label, sort_fields))
return '\n'.join(output)
|
'MPTTFilteredSelectMultiple\'s Media.'
| @property
def media(self):
| js = ['admin/js/core.js', 'zinnia/admin/mptt/js/mptt_m2m_selectbox.js', 'admin/js/SelectFilter2.js']
return Media(js=[staticfiles_storage.url(path) for path in js])
|
'Returns the list of tags to auto-complete.'
| def get_tags(self):
| return [tag.name for tag in Tag.objects.usage_for_model(Entry)]
|
'Render the default widget and initialize select2.'
| def render(self, name, value, attrs=None):
| output = [super(TagAutoComplete, self).render(name, value, attrs)]
output.append('<script type="text/javascript">')
output.append('(function($) {')
output.append(' $(document).ready(function() {')
output.append((' $("#id_%s").select2({' % name))
output.append(' ... |
'TagAutoComplete\'s Media.'
| @property
def media(self):
| def static(path):
return staticfiles_storage.url(('zinnia/admin/select2/%s' % path))
return Media(css={'all': (static('css/select2.css'),)}, js=(static('js/select2.js'),))
|
'Return the title with word count and number of comments.'
| def get_title(self, entry):
| title = (_(u'%(title)s (%(word_count)i words)') % {u'title': entry.title, u'word_count': entry.word_count})
reaction_count = int(((entry.comment_count + entry.pingback_count) + entry.trackback_count))
if reaction_count:
return (ungettext_lazy(u'%(title)s (%(reactions)i reaction)', u'%(ti... |
'Return the authors in HTML.'
| def get_authors(self, entry):
| try:
return format_html_join(u', ', u'<a href="{}" target="blank">{}</a>', [(author.get_absolute_url(), getattr(author, author.USERNAME_FIELD)) for author in entry.authors.all()])
except NoReverseMatch:
return u', '.join([conditional_escape(getattr(author, author.USERNAME_FIELD)) for... |
'Return the categories linked in HTML.'
| def get_categories(self, entry):
| try:
return format_html_join(u', ', u'<a href="{}" target="blank">{}</a>', [(category.get_absolute_url(), category.title) for category in entry.categories.all()])
except NoReverseMatch:
return u', '.join([conditional_escape(category.title) for category in entry.categories.all()])
|
'Return the tags linked in HTML.'
| def get_tags(self, entry):
| try:
return format_html_join(u', ', u'<a href="{}" target="blank">{}</a>', [(reverse(u'zinnia:tag_detail', args=[tag]), tag) for tag in entry.tags_list])
except NoReverseMatch:
return conditional_escape(entry.tags)
|
'Return the sites linked in HTML.'
| def get_sites(self, entry):
| try:
index_url = reverse(u'zinnia:entry_archive_index')
except NoReverseMatch:
index_url = u''
return format_html_join(u', ', u'<a href="{}://{}{}" target="blank">{}</a>', [(settings.PROTOCOL, site.domain, index_url, conditional_escape(site.name)) for site in entry.sites.all()])
|
'Return the short url in HTML.'
| def get_short_url(self, entry):
| try:
short_url = entry.short_url
except NoReverseMatch:
short_url = entry.get_absolute_url()
return format_html(u'<a href="{url}" target="blank">{url}</a>', url=short_url)
|
'Admin wrapper for entry.is_visible.'
| def get_is_visible(self, entry):
| return entry.is_visible
|
'Make special filtering by user\'s permissions.'
| def get_queryset(self, request):
| if (not request.user.has_perm(u'zinnia.can_view_all')):
queryset = self.model.objects.filter(authors__pk=request.user.pk)
else:
queryset = super(EntryAdmin, self).get_queryset(request)
return queryset.prefetch_related(u'categories', u'authors', u'sites')
|
'Provide initial datas when creating an entry.'
| def get_changeform_initial_data(self, request):
| get_data = super(EntryAdmin, self).get_changeform_initial_data(request)
return (get_data or {u'sites': [Site.objects.get_current().pk], u'authors': [request.user.pk]})
|
'Filter the disposable authors.'
| def formfield_for_manytomany(self, db_field, request, **kwargs):
| if (db_field.name == u'authors'):
kwargs[u'queryset'] = Author.objects.filter((Q(is_staff=True) | Q(entries__isnull=False))).distinct()
return super(EntryAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)
|
'Return readonly fields by user\'s permissions.'
| def get_readonly_fields(self, request, obj=None):
| readonly_fields = list(super(EntryAdmin, self).get_readonly_fields(request, obj))
if (not request.user.has_perm(u'zinnia.can_change_status')):
readonly_fields.append(u'status')
if (not request.user.has_perm(u'zinnia.can_change_author')):
readonly_fields.append(u'authors')
return readonly... |
'Define actions by user\'s permissions.'
| def get_actions(self, request):
| actions = super(EntryAdmin, self).get_actions(request)
if (not actions):
return actions
if ((not request.user.has_perm(u'zinnia.can_change_author')) or (not request.user.has_perm(u'zinnia.can_view_all'))):
del actions[u'make_mine']
if (not request.user.has_perm(u'zinnia.can_change_status... |
'Set the entries to the current user.'
| def make_mine(self, request, queryset):
| author = Author.objects.get(pk=request.user.pk)
for entry in queryset:
if (author not in entry.authors.all()):
entry.authors.add(author)
self.message_user(request, _(u'The selected entries now belong to you.'))
|
'Set entries selected as published.'
| def make_published(self, request, queryset):
| queryset.update(status=PUBLISHED)
EntryPublishedVectorBuilder().cache_flush()
self.ping_directories(request, queryset, messages=False)
self.message_user(request, _(u'The selected entries are now marked as published.'))
|
'Set entries selected as hidden.'
| def make_hidden(self, request, queryset):
| queryset.update(status=HIDDEN)
EntryPublishedVectorBuilder().cache_flush()
self.message_user(request, _(u'The selected entries are now marked as hidden.'))
|
'Close the comments for selected entries.'
| def close_comments(self, request, queryset):
| queryset.update(comment_enabled=False)
self.message_user(request, _(u'Comments are now closed for selected entries.'))
|
'Close the pingbacks for selected entries.'
| def close_pingbacks(self, request, queryset):
| queryset.update(pingback_enabled=False)
self.message_user(request, _(u'Pingbacks are now closed for selected entries.'))
|
'Close the trackbacks for selected entries.'
| def close_trackbacks(self, request, queryset):
| queryset.update(trackback_enabled=False)
self.message_user(request, _(u'Trackbacks are now closed for selected entries.'))
|
'Put the selected entries on top at the current date.'
| def put_on_top(self, request, queryset):
| queryset.update(publication_date=timezone.now())
self.ping_directories(request, queryset, messages=False)
self.message_user(request, _(u'The selected entries are now set at the current date.'))
|
'Mark selected as featured post.'
| def mark_featured(self, request, queryset):
| queryset.update(featured=True)
self.message_user(request, _(u'Selected entries are now marked as featured.'))
|
'Un-Mark selected featured posts.'
| def unmark_featured(self, request, queryset):
| queryset.update(featured=False)
self.message_user(request, _(u'Selected entries are no longer marked as featured.'))
|
'Ping web directories for selected entries.'
| def ping_directories(self, request, queryset, messages=True):
| for directory in settings.PING_DIRECTORIES:
pinger = DirectoryPinger(directory, queryset)
pinger.join()
if messages:
success = 0
for result in pinger.results:
if (not result.get(u'flerror', True)):
success += 1
else:... |
'Return the category\'s tree path in HTML.'
| def get_tree_path(self, category):
| try:
return format_html('<a href="{}" target="blank">/{}/</a>', category.get_absolute_url(), category.tree_path)
except NoReverseMatch:
return ('/%s/' % category.tree_path)
|
'Return published objects with the number of entries.'
| def lookups(self, request, model_admin):
| active_objects = self.model.published.all().annotate(count_entries_published=Count('entries')).order_by('-count_entries_published', '-pk')
for active_object in active_objects:
(yield (str(active_object.pk), (ungettext_lazy('%(item)s (%(count)i entry)', '%(item)s (%(count)i entries)', active_... |
'Return the object\'s entries if a value is set.'
| def queryset(self, request, queryset):
| if self.value():
params = {self.lookup_key: self.value()}
return queryset.filter(**params)
|
'Check if category parent is not selfish.'
| def clean_parent(self):
| data = self.cleaned_data['parent']
if (data == self.instance):
raise forms.ValidationError(_('A category cannot be parent of itself.'), code='self_parenting')
return data
|
'Ping entries to a directory in a thread.'
| def run(self):
| logger = getLogger('zinnia.ping.directory')
socket.setdefaulttimeout(self.timeout)
for entry in self.entries:
reply = self.ping_entry(entry)
self.results.append(reply)
logger.info('%s : %s', self.server_name, reply['message'])
socket.setdefaulttimeout(None)
|
'Ping an entry to a directory.'
| def ping_entry(self, entry):
| entry_url = ('%s%s' % (self.ressources.site_url, entry.get_absolute_url()))
categories = '|'.join([c.title for c in entry.categories.all()])
try:
reply = self.server.weblogUpdates.extendedPing(self.ressources.current_site.name, self.ressources.blog_url, entry_url, self.ressources.blog_feed, categori... |
'Ping external URLs in a Thread.'
| def run(self):
| logger = getLogger('zinnia.ping.external_urls')
socket.setdefaulttimeout(self.timeout)
external_urls = self.find_external_urls(self.entry)
external_urls_pingable = self.find_pingback_urls(external_urls)
for (url, server_name) in external_urls_pingable.items():
reply = self.pingback_url(serve... |
'Check if the URL is an external URL.'
| def is_external_url(self, url, site_url):
| url_splitted = urlsplit(url)
if (not url_splitted.netloc):
return False
return (url_splitted.netloc != urlsplit(site_url).netloc)
|
'Find external URLs in an entry.'
| def find_external_urls(self, entry):
| soup = BeautifulSoup(entry.html_content, 'html.parser')
external_urls = [a['href'] for a in soup.find_all('a') if self.is_external_url(a['href'], self.ressources.site_url)]
return external_urls
|
'Try to find LINK markups to pingback URL.'
| def find_pingback_href(self, content):
| soup = BeautifulSoup(content, 'html.parser')
for link in soup.find_all('link'):
dict_attr = dict(link.attrs)
if (('rel' in dict_attr) and ('href' in dict_attr)):
for rel_type in dict_attr['rel']:
if (rel_type.lower() == PINGBACK):
return dict_attr.... |
'Find the pingback URL for each URLs.'
| def find_pingback_urls(self, urls):
| pingback_urls = {}
for url in urls:
try:
page = urlopen(url)
headers = page.info()
server_url = headers.get('X-Pingback')
if (not server_url):
content_type = headers.get('Content-Type', '').split(';')[0].strip().lower()
if (... |
'Do a pingback call for the target URL.'
| def pingback_url(self, server_name, target_url):
| try:
server = ServerProxy(server_name)
reply = server.pingback.ping(self.entry_url, target_url)
except (Error, socket.error):
reply = ('%s cannot be pinged.' % target_url)
return reply
|
'Return published entries.'
| def get_queryset(self):
| return entries_published(super(EntryPublishedManager, self).get_queryset())
|
'Return entries published on current site.'
| def on_site(self):
| return super(EntryPublishedManager, self).get_queryset().filter(sites=Site.objects.get_current())
|
'Top level search method on entries.'
| def search(self, pattern):
| try:
return self.advanced_search(pattern)
except:
return self.basic_search(pattern)
|
'Advanced search on entries.'
| def advanced_search(self, pattern):
| from zinnia.search import advanced_search
return advanced_search(pattern)
|
'Basic search on entries.'
| def basic_search(self, pattern):
| lookup = None
for pattern in pattern.split():
query_part = models.Q()
for field in SEARCH_FIELDS:
query_part |= models.Q(**{('%s__icontains' % field): pattern})
if (lookup is None):
lookup = query_part
else:
lookup |= query_part
return self... |
'Return a queryset containing published entries.'
| def get_queryset(self):
| now = timezone.now()
return super(EntryRelatedPublishedManager, self).get_queryset().filter((models.Q(entries__start_publication__lte=now) | models.Q(entries__start_publication=None)), (models.Q(entries__end_publication__gt=now) | models.Q(entries__end_publication=None)), entries__status=PUBLISHED, entries__sit... |
'Title of the feed prefixed with the site name.'
| def title(self, obj=None):
| return ('%s - %s' % (self.site.name, self.get_title(obj)))
|
'Acquire the current site used.'
| @property
def site(self):
| return Site.objects.get_current()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.