This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Article sorting for Ajax--> | |
<select title="{{ _('Select sort param') }}" class="selectpicker" id="sort" | |
data-url="{{ url('articles:sort') }}"> | |
<option value="-create_date" data-icon="glyphicon glyphicon-arrow-up"> | |
{{ _('Date') }} | |
</option> | |
<option value="create_date" data-icon="glyphicon glyphicon-arrow-down"> | |
{{ _('Date') }} | |
</option> | |
<option value="-rate" data-icon="glyphicon glyphicon-arrow-up"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include before main script file and after jquery (or after jquery if everything in one file) | |
$(document).ready(function(){ | |
... | |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Cross Site Request Forgery protection~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie != '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery.schedules import crontab | |
from services import crawlers | |
from celery.task.base import periodic_task | |
from celery.utils.log import get_task_logger | |
logger = get_task_logger(__name__) | |
@periodic_task(run_every=(crontab(hour="*", minute="*", day_of_week="*"))) | |
def update_githab(): | |
# logger.info("Start task") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% load static %} | |
{% load widget_tweaks %} | |
{% load i18n %} | |
{% block content %} | |
<div class="row"> | |
<div class="col-md-10 col-md-offset-1"> | |
<h2> | |
{% if action == 'update' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Article - your model | |
# Action, Like - Generic Relation models | |
# Deleting action and likes, associated with article, if we deleting article | |
def deleted_gfk_Action(sender, instance, using, **kwargs): | |
ctype = ContentType.objects.get_for_model(sender) | |
try: | |
action_objs = Action.objects.filter(target_ct=ctype, target_id=instance.id) | |
like_objs = Like.objects.filter(content_type=ctype, object_id=instance.id) | |
except Action.DoesNotExist: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Another jinja template for variant with cache categories--> | |
<ul class="categories"> | |
<li> | |
<form id="all_categories_form" action="{{ url('articles:home') }}" method="get"> | |
<input type="hidden" name="is_clear" value="True"> | |
<a href="#" onclick="document.getElementById('all_categories_form').submit();">All</a> | |
</form> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for hidden_field in form.hidden_fields() %} | |
{{ hidden_field }} | |
{% endfor %} | |
{% if form.non_field_errors %} | |
{% for error in form.non_field_errors() %} | |
{{ error }} | |
{% endfor %} | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- With bootstrap accordeon for category's children --> | |
<ul class="categories"> | |
<li> | |
<form id="all_categories_form" action="{{ url('articles:home') }}" method="get"> | |
<input type="hidden" name="is_clear" value="True"> | |
<a href="#" onclick="document.getElementById('all_categories_form').submit();">All</a> | |
</form> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EditProfileView(LoginRequiredMixin, SuccessMessageMixin, FormView): | |
model = User | |
template_name = 'accounts/settings/settings.html' | |
success_message = _('Your profile was successfully updated!') | |
form_class = UserForm | |
second_form_class = ProfileForm | |
def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | |
if 'user_form' not in context: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticleForm(TranslatableModelForm): | |
title = TranslatedField() | |
short_description = TranslatedField( | |
label=_('Short description'), | |
required=False, | |
help_text=_("You can use html tags for short description. Max length: 1000 characters.")) | |
content = TranslatedField( | |
label=_('Content'), | |
form_class=forms.CharField, | |
widget=TinyMCE, |