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 django.contrib import admin | |
from .models import Like | |
admin.site.register(Like) |
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 VariantImageAdminInline(admin.TabularInline): | |
model = VariantImage | |
def formfield_for_foreignkey(self, db_field, request=None, **kwargs): | |
"""enable ordering drop-down alphabetically""" | |
if db_field.name == 'image': | |
resolved = resolve(request.path_info) | |
if resolved.args: | |
parent_object = self.parent_model.objects.filter(pk=resolved.args[0]).first() |
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
# saves images to folder with class name if it is generic relation gallery | |
def image_upload_to(instance, filename): | |
return "{}//{}".format(slugify(instance.content_object.__class__.__name__), filename) | |
# the same but for abstarct class | |
def image_upload_to(instance, filename): | |
return "{}//{}".format(slugify(instance.__class__.__name__), filename) | |
# saves image with user full name (for profile image) | |
def image_upload_to(instance, filename): |
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 django import forms | |
from django.utils.translation import ugettext_lazy as _ | |
from apps.country.models.country import Country | |
from apps.country.models.resort import Resort | |
from apps.hotel import HotelStars | |
from apps.hotel.models import HotelType | |
class HotelFilterForm(forms.Form): | |
country = forms.ModelMultipleChoiceField( |
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
$(document).ready(function() { | |
// pagination with appending objects (load more pagination) | |
$(".infinite-more-link").click(function(e) { | |
var link = $(this); | |
var page = link.data('page') | |
$.ajax({ | |
method: 'GET', | |
url: $(this).data('url'), | |
data: { | |
'page': page |
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
$(document).ready(function() { | |
$('.about__change-select').on('change', function(){ | |
var option = $('option:selected', this).data('price'); | |
$('.date_price').text(Math.floor(option).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ")) | |
}) | |
}) |
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 __future__ import unicode_literals | |
import logging | |
from django.utils.translation import ugettext_lazy as _ | |
logger = logging.getLogger(__name__) | |
class TemplatesChoices: |
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
a.header-top__login(href=exp("url('accounts:logout')")+"?next=" + exp("df.urlencode(request.path)")) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | |
</head> | |
<body> |
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
""" Function for applying watermarks to images. | |
Original found here: | |
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879 | |
""" | |
try: | |
import Image | |
import ImageEnhance | |
except ImportError: | |
try: |