|
|
|
|
@ -164,14 +164,13 @@ |
|
|
|
|
</div> |
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
<div class="galleryWork2 disTab"> |
|
|
|
|
<div class="galleryWork2 disTab -portfolios-container"> |
|
|
|
|
{% if False %} |
|
|
|
|
{% for p in contractor.portfolios.all %} |
|
|
|
|
<div class="col-lg-4"> |
|
|
|
|
<div class="insetCol box-sizing disTab"> |
|
|
|
|
{% thumbnail p.get_cover "224x224" crop="center" as im %} |
|
|
|
|
<div class="imgGal" |
|
|
|
|
style="background:rgba(0, 0, 0, 0) url('{{ im.url }}') no-repeat scroll center center / cover ;"> |
|
|
|
|
<div class="imgGal" style="background:rgba(0, 0, 0, 0) url('{{ im.url }}') no-repeat scroll center center / cover ;"> |
|
|
|
|
<a class="open-modal-image" href="{{ p.get_cover.url }}"><div class="imgFigure"></div></a> |
|
|
|
|
</div> |
|
|
|
|
{% endthumbnail %} |
|
|
|
|
@ -207,23 +206,42 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/template" class="-portfolio-item-templ"> |
|
|
|
|
{# <div class="col-lg-4">#} |
|
|
|
|
{# <div class="insetCol box-sizing disTab">#} |
|
|
|
|
{# <div class="imgGal" style="background:rgba(0, 0, 0, 0) url('<%= portfolio.photos[0].img %>') no-repeat scroll center center / cover">#} |
|
|
|
|
{# <div class="imgFigure"></div>#} |
|
|
|
|
{# </div>#} |
|
|
|
|
{# </div>#} |
|
|
|
|
{# #} |
|
|
|
|
{# <div class="insetCol2 box-sizing disTab text-center">#} |
|
|
|
|
{# <a href="<%= portfAbsUrl %>"><%= trunc({length: 50}, portfolio.name) %></a>#} |
|
|
|
|
{# </div>#} |
|
|
|
|
{# </div>#} |
|
|
|
|
<div class="col-lg-4"> |
|
|
|
|
<div class="insetCol box-sizing disTab"> |
|
|
|
|
<div class="imgGal" style="background:rgba(0, 0, 0, 0) url('<%= portfolio.photos[0].img %>') no-repeat scroll center center / cover"> |
|
|
|
|
<a class="open-modal-image" href="<%= portfolio.photos[0].img %>"><div class="imgFigure"></div></a> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="insetCol2 box-sizing disTab"> |
|
|
|
|
<a href="<%= portfAbsUrl %>"><%= trunc({length: 50}, portfolio.name) %></a> |
|
|
|
|
|
|
|
|
|
{% if False %} |
|
|
|
|
{% if request.user.pk == contractor.pk %} |
|
|
|
|
<div class="buttonsImg" disTab> |
|
|
|
|
<a href="{% url 'projects:contractor-portfolio-edit' p.pk %}"> |
|
|
|
|
<div class="insetBI insetBI1"> |
|
|
|
|
<i class="fa fa-pencil"></i> |
|
|
|
|
</div> |
|
|
|
|
</a> |
|
|
|
|
<div class="insetBI insetBI2"> |
|
|
|
|
<form action="{% url 'projects:contractor-portfolio-trash' pk=p.pk %}" method="POST" novalidate> |
|
|
|
|
{% csrf_token %} |
|
|
|
|
<input type="hidden" name="next" value="{{ request.path }}"> |
|
|
|
|
<a href="#" onclick="$(this).closest('form').submit(); return false"><i class="fa fa-times"></i></a> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
{% endif %} |
|
|
|
|
{% endif %} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</script> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="col-lg-9 col-lg-offset-3"> |
|
|
|
|
<div class="linkElse"> |
|
|
|
|
<a href="javascript:void(0)" class="showElse">показать еще</a> |
|
|
|
|
<a href="#" onclick="loadMorePortfolios(); return false" class="showElse">показать еще</a> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
@ -249,28 +267,71 @@ |
|
|
|
|
</div> |
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
<div class="galleryWork2 disTab"> |
|
|
|
|
{% for ws in contractor.work_sell.all %} |
|
|
|
|
<div class="galleryWork2 disTab -work-sells-container"> |
|
|
|
|
{% if False %} |
|
|
|
|
{% for ws in contractor.work_sell.all %} |
|
|
|
|
<div class="col-lg-4"> |
|
|
|
|
<div class="insetCol box-sizing disTab"> |
|
|
|
|
<a href="{% url 'work_sell:detail' ws.pk %}"> |
|
|
|
|
{% thumbnail ws.get_cover "224x224" crop="center" as im %} |
|
|
|
|
<div class="imgGal" |
|
|
|
|
style="background:rgba(0, 0, 0, 0) url('{{ im.url }}') no-repeat scroll center center / cover ;"> |
|
|
|
|
<a class="open-modal-image" href="{{ ws.get_cover.url }}"><div class="imgFigure"></div></a> |
|
|
|
|
</div> |
|
|
|
|
{% endthumbnail %} |
|
|
|
|
</a> |
|
|
|
|
|
|
|
|
|
<div class="cenaImg box-sizing"> |
|
|
|
|
<div class="cenaImgInset"> |
|
|
|
|
{{ ws.budget }} <i class="fa fa-rub"></i> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="insetCol2 box-sizing disTab"> |
|
|
|
|
<a href="{% url 'work_sell:detail' ws.pk %}">{{ ws }}</a> |
|
|
|
|
{% if request.user.pk == contractor.pk %} |
|
|
|
|
<div class="buttonsImg" disTab> |
|
|
|
|
<div class="insetBI insetBI1"> |
|
|
|
|
<a href="{% url 'work_sell:edit' ws.pk %}"> |
|
|
|
|
<i class="fa fa-pencil"></i> |
|
|
|
|
</a> |
|
|
|
|
</div> |
|
|
|
|
<div class="insetBI insetBI2"> |
|
|
|
|
<form action="{% url 'work_sell:contractor-worksell-trash' pk=ws.pk %}" method="POST" novalidate> |
|
|
|
|
{% csrf_token %} |
|
|
|
|
<input type="hidden" name="next" value="{{ request.path }}"> |
|
|
|
|
<a href="#" onclick="$(this).closest('form').submit(); return false"><i class="fa fa-times"></i></a> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
{% endif %} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
{% endfor %} |
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/template" class="-work-sell-item-templ"> |
|
|
|
|
<div class="col-lg-4"> |
|
|
|
|
<div class="insetCol box-sizing disTab"> |
|
|
|
|
<a href="{% url 'work_sell:detail' ws.pk %}"> |
|
|
|
|
{% thumbnail ws.get_cover "224x224" crop="center" as im %} |
|
|
|
|
<div class="imgGal" |
|
|
|
|
style="background:rgba(0, 0, 0, 0) url('{{ im.url }}') no-repeat scroll center center / cover ;"> |
|
|
|
|
<a class="open-modal-image" href="{{ ws.get_cover.url }}"><div class="imgFigure"></div></a> |
|
|
|
|
</div> |
|
|
|
|
{% endthumbnail %} |
|
|
|
|
{# <a href="{% url 'work_sell:detail' ws.pk %}">#} |
|
|
|
|
<a href="#"> |
|
|
|
|
<div class="imgGal" style="background:rgba(0, 0, 0, 0) url('<%= workSell.photos[0].img %>') no-repeat scroll center center / cover"> |
|
|
|
|
<a class="open-modal-image" href="<%= workSell.photos[0].img %>"><div class="imgFigure"></div></a> |
|
|
|
|
</div> |
|
|
|
|
</a> |
|
|
|
|
|
|
|
|
|
<div class="cenaImg box-sizing"> |
|
|
|
|
<div class="cenaImgInset"> |
|
|
|
|
{{ ws.budget }} <i class="fa fa-rub"></i> |
|
|
|
|
<%= workSell.budget %> <i class="fa fa-rub"></i> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="insetCol2 box-sizing disTab"> |
|
|
|
|
<a href="{% url 'work_sell:detail' ws.pk %}">{{ ws }}</a> |
|
|
|
|
{% if request.user.pk == contractor.pk %} |
|
|
|
|
<a href="<%= workSellAbsUrl %>"><%= trunc({length: 50}, workSell.name) %></a> |
|
|
|
|
|
|
|
|
|
{% if False and request.user.pk == contractor.pk %} |
|
|
|
|
<div class="buttonsImg" disTab> |
|
|
|
|
<div class="insetBI insetBI1"> |
|
|
|
|
<a href="{% url 'work_sell:edit' ws.pk %}"> |
|
|
|
|
@ -288,11 +349,12 @@ |
|
|
|
|
{% endif %} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
{% endfor %} |
|
|
|
|
</script> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="col-lg-9 col-lg-offset-3"> |
|
|
|
|
<div class="linkElse"> |
|
|
|
|
<a href="javascript:void(0)" class="showElse">показать еще</a> |
|
|
|
|
<a href="#" onclick="loadMoreWorkSells(); return false" class="showElse">показать еще</a> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
@ -498,27 +560,102 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% block js_block %} |
|
|
|
|
<script type="text/javascript" src='{% static "js/jquery.magnific-popup.min.js" %}'></script> |
|
|
|
|
|
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
var userId = '{{ contractor.pk }}'; |
|
|
|
|
$(function () { |
|
|
|
|
|
|
|
|
|
;(function() { |
|
|
|
|
// Pagination --------------------------------------------------- |
|
|
|
|
|
|
|
|
|
var $portfoliosContainer = $('.-portfolios-container').first() |
|
|
|
|
var portfolioItemTempl = _.template($portfoliosContainer.find('.-portfolio-item-templ').first().html()) |
|
|
|
|
var $morePortfBtn = $('.-more-portfolios-btn').first() |
|
|
|
|
var portfAbsUrl = '/projects/portfolio/' |
|
|
|
|
|
|
|
|
|
var $workSellsContainer = $('.-work-sells-container').first() |
|
|
|
|
var workSellItemTempl = _.template($workSellsContainer.find('.-work-sell-item-templ').first().html()) |
|
|
|
|
var $moreWorkSellsfBtn = $('.-more-work-sells-btn').first() |
|
|
|
|
var workSellAbsUrl = '/work_sell/' |
|
|
|
|
|
|
|
|
|
var teamId = {{ contractor.team.pk }} |
|
|
|
|
var contractorIds |
|
|
|
|
|
|
|
|
|
var portfUrl = new URI('/api/portfolios/') |
|
|
|
|
var workSellUrl = new URI('/api/work-sells/') |
|
|
|
|
var pageSize = 3 |
|
|
|
|
|
|
|
|
|
$.get('/api/teams/' + teamId + '/').then(function(res) { |
|
|
|
|
contractorIds = _.map(function(contractor) { |
|
|
|
|
return contractor.id |
|
|
|
|
}, res.contractors) |
|
|
|
|
}) |
|
|
|
|
.then(loadMorePortfolios) |
|
|
|
|
.then(loadMoreWorkSells) |
|
|
|
|
|
|
|
|
|
function loadMorePortfolios() { |
|
|
|
|
var query = portfUrl.query(true) |
|
|
|
|
|
|
|
|
|
portfUrl.setQuery('user__id__in', _.join(',', contractorIds)) |
|
|
|
|
portfUrl.setQuery('page_size', pageSize) |
|
|
|
|
portfUrl.setQuery('page', query.page ? Number(query.page) + 1 : 2) |
|
|
|
|
|
|
|
|
|
$.get(portfUrl.href()) |
|
|
|
|
.then(function(res) { |
|
|
|
|
_.each(function(portfolio) { |
|
|
|
|
$portfoliosContainer.append(portfolioItemTempl({ |
|
|
|
|
portfolio: portfolio, |
|
|
|
|
portfAbsUrl: portfAbsUrl + portfolio.id + '/', |
|
|
|
|
trunc: _.truncate, |
|
|
|
|
})) |
|
|
|
|
}, res.results) |
|
|
|
|
|
|
|
|
|
if (!res.next) |
|
|
|
|
$morePortfBtn.css('display', 'none') |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
.then(function() { |
|
|
|
|
$('.open-modal-image').magnificPopup({type: 'image'}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function loadMoreWorkSells() { |
|
|
|
|
var query = workSellUrl.query(true) |
|
|
|
|
|
|
|
|
|
workSellUrl.setQuery('contractor__in', _.join(',', contractorIds)) |
|
|
|
|
workSellUrl.setQuery('page_size', pageSize) |
|
|
|
|
workSellUrl.setQuery('page', query.page ? Number(query.page) + 1 : 2) |
|
|
|
|
|
|
|
|
|
$.get(workSellUrl.href()).then(function(res) { |
|
|
|
|
_.each(function(ws) { |
|
|
|
|
$workSellsContainer.append(workSellItemTempl({ |
|
|
|
|
workSell: ws, |
|
|
|
|
workSellAbsUrl: workSellAbsUrl + ws.id + '/', |
|
|
|
|
trunc: _.truncate, |
|
|
|
|
})) |
|
|
|
|
}, res.results) |
|
|
|
|
|
|
|
|
|
if (!res.next) |
|
|
|
|
$moreWorkSellsfBtn.css('display', 'none') |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.loadMorePortfolios = loadMorePortfolios |
|
|
|
|
window.loadMoreWorkSells = loadMoreWorkSells |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userId = '{{ contractor.pk }}'; |
|
|
|
|
|
|
|
|
|
var hash = window.location.hash; |
|
|
|
|
|
|
|
|
|
if (hash == '#open-contact'){ |
|
|
|
|
$("#contact-contactor-modal").modal(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('.open-modal-image').magnificPopup({ |
|
|
|
|
type: 'image' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#resume-edit-form').on('submit', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var resumeEditUrl = "{% url 'users:contractor-resume-update' contractor.contractor_resume.pk %}"; |
|
|
|
|
var dataSerializer = $(this).serialize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: resumeEditUrl, |
|
|
|
|
method: 'POST', |
|
|
|
|
@ -532,7 +669,7 @@ |
|
|
|
|
if (data.status == 'ok') { |
|
|
|
|
$("#resume-text-out").html(data.text); |
|
|
|
|
$("#resume-text-edit").modal('hide'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error: function (jqXHR, exception) { |
|
|
|
|
@ -540,14 +677,14 @@ |
|
|
|
|
console.log(exception); |
|
|
|
|
console.log(jqXHR.statusCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#diplom-cro-gallery").on('click', '.delete-resume-file',function(e){ |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _this = $(this); |
|
|
|
|
var deleteResumeUrl = '/api/contractorresumefiles/' + $(this).attr('data-id') + '/'; |
|
|
|
|
$.ajax({ |
|
|
|
|
@ -565,8 +702,8 @@ |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#worksell-add-form').on('submit', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var dataSerializer = $(this).serialize(); |
|
|
|
|
@ -579,21 +716,21 @@ |
|
|
|
|
if (data.status == 'ok') { |
|
|
|
|
location.reload(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
error: function (jqXHR, exception) { |
|
|
|
|
console.log(jqXHR.statusCode); |
|
|
|
|
console.log(jqXHR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#portfolio-add-form').on('submit', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var dataSerializer = $(this).serialize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/projects/portfolio/create/', |
|
|
|
|
method: 'POST', |
|
|
|
|
@ -606,7 +743,7 @@ |
|
|
|
|
}); |
|
|
|
|
location.reload(); |
|
|
|
|
} else if (data.status == 'no') { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.each(data.form_errors, function (k, v) { |
|
|
|
|
$('.error-' + k).html(v).show(); |
|
|
|
|
}); |
|
|
|
|
@ -619,7 +756,7 @@ |
|
|
|
|
}); |
|
|
|
|
var url = '/work_sell/basic/'; |
|
|
|
|
var csrftoken = $.cookie('csrftoken'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#upload-resume").on('change',function(e){ |
|
|
|
|
$("#resume-success").html(""); |
|
|
|
|
var formData = new FormData($(this).closest("form")); |
|
|
|
|
@ -647,7 +784,7 @@ |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#fileupload').fileupload({ |
|
|
|
|
url: url, |
|
|
|
|
crossDomain: false, |
|
|
|
|
@ -669,7 +806,7 @@ |
|
|
|
|
var currentValue = $("#upload-files-pk").val(); |
|
|
|
|
currentValue += file.id + ';'; |
|
|
|
|
$("#upload-files-pk").val(currentValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
progressall: function (e, data) { |
|
|
|
|
@ -682,7 +819,7 @@ |
|
|
|
|
} |
|
|
|
|
}).prop('disabled', !$.support.fileInput) |
|
|
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#fileupload-worksell').fileupload({ |
|
|
|
|
url: url, |
|
|
|
|
crossDomain: false, |
|
|
|
|
@ -704,7 +841,7 @@ |
|
|
|
|
var currentValue = $("#upload-files-worksell-pk").val(); |
|
|
|
|
currentValue += file.id + ';'; |
|
|
|
|
$("#upload-files-worksell-pk").val(currentValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
progressall: function (e, data) { |
|
|
|
|
@ -717,9 +854,9 @@ |
|
|
|
|
} |
|
|
|
|
}).prop('disabled', !$.support.fileInput) |
|
|
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function add_resume_file(resumeType, imgUrl,imgPk, galleryId){ |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/users/contractorsresumefiles/create/', |
|
|
|
|
@ -734,7 +871,7 @@ |
|
|
|
|
var htmlImg = '<div class="col-lg-4"><div class="insetCol box-sizing disTab"><div class="imgGal" style="background: url(' + imgUrl +') no-repeat center;"><div class="imgFigure"></div></div></div> ' + |
|
|
|
|
'<div class="insetCol2 box-sizing disTab"><div class="buttonsImg" distab="">' + |
|
|
|
|
'<div class="insetBI insetBI2 delete-resume-file" data-id="' + data.pk +'"><i class="fa fa-times"></i></div></div></div></div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var img = $(htmlImg).appendTo(galleryId); |
|
|
|
|
} else if (data.status == 'no') { |
|
|
|
|
$.each(data.form_errors, function (k, v) { |
|
|
|
|
@ -775,7 +912,7 @@ |
|
|
|
|
} |
|
|
|
|
}).prop('disabled', !$.support.fileInput) |
|
|
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#cro-upload').fileupload({ |
|
|
|
|
url: url, |
|
|
|
|
crossDomain: false, |
|
|
|
|
@ -803,90 +940,11 @@ |
|
|
|
|
} |
|
|
|
|
}).prop('disabled', !$.support.fileInput) |
|
|
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function csrfSafeMethod(method) { |
|
|
|
|
// these HTTP methods do not require CSRF protection |
|
|
|
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Pagination ------------------------------------------------------------> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
(function() { |
|
|
|
|
var $portfoliosContainer = $('.-portfolios-container').first() |
|
|
|
|
var portfolioItemTempl = _.template($portfoliosContainer.find('.-portfolio-item-templ').first().html()) |
|
|
|
|
var $morePortfBtn = $('.-more-portfolios-btn').first() |
|
|
|
|
var portfAbsUrl = '/projects/portfolio/' |
|
|
|
|
|
|
|
|
|
var $workSellsContainer = $('.-work-sells-container').first() |
|
|
|
|
var workSellItemTempl = _.template($workSellsContainer.find('.-work-sell-item-templ').first().html()) |
|
|
|
|
var $moreWorkSellsfBtn = $('.-more-work-sells-btn').first() |
|
|
|
|
var workSellAbsUrl = '/work_sell/' |
|
|
|
|
|
|
|
|
|
var teamId = {{ contractor.team.pk }} |
|
|
|
|
var contractorIds |
|
|
|
|
|
|
|
|
|
var portfUrl = new URI('/api/portfolios/') |
|
|
|
|
var workSellUrl = new URI('/api/work-sells/') |
|
|
|
|
var pageSize = 3 |
|
|
|
|
|
|
|
|
|
$.get('/api/teams/' + teamId + '/').then(function(res) { |
|
|
|
|
contractorIds = _.map(function(contractor) { |
|
|
|
|
return contractor.id |
|
|
|
|
}, res.contractors) |
|
|
|
|
}) |
|
|
|
|
.then(loadMorePortfolios) |
|
|
|
|
.then(loadMoreWorkSells) |
|
|
|
|
|
|
|
|
|
function loadMorePortfolios() { |
|
|
|
|
var query = portfUrl.query(true) |
|
|
|
|
|
|
|
|
|
portfUrl.setQuery('user__id__in', _.join(',', contractorIds)) |
|
|
|
|
portfUrl.setQuery('page_size', pageSize) |
|
|
|
|
portfUrl.setQuery('page', query.page ? Number(query.page) + 1 : 2) |
|
|
|
|
|
|
|
|
|
$.get(portfUrl.href()).then(function(res) { |
|
|
|
|
_.each(function(portfolio) { |
|
|
|
|
$portfoliosContainer.append(portfolioItemTempl({ |
|
|
|
|
portfolio: portfolio, |
|
|
|
|
portfAbsUrl: portfAbsUrl + portfolio.id + '/', |
|
|
|
|
trunc: _.truncate, |
|
|
|
|
})) |
|
|
|
|
}, res.results) |
|
|
|
|
|
|
|
|
|
if (!res.next) |
|
|
|
|
$morePortfBtn.css('display', 'none') |
|
|
|
|
}) |
|
|
|
|
function csrfSafeMethod(method) { |
|
|
|
|
// these HTTP methods do not require CSRF protection |
|
|
|
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function loadMoreWorkSells() { |
|
|
|
|
var query = workSellUrl.query(true) |
|
|
|
|
|
|
|
|
|
workSellUrl.setQuery('contractor__in', _.join(',', contractorIds)) |
|
|
|
|
workSellUrl.setQuery('page_size', pageSize) |
|
|
|
|
workSellUrl.setQuery('page', query.page ? Number(query.page) + 1 : 2) |
|
|
|
|
|
|
|
|
|
$.get(workSellUrl.href()).then(function(res) { |
|
|
|
|
_.each(function(ws) { |
|
|
|
|
$workSellsContainer.append(workSellItemTempl({ |
|
|
|
|
workSell: ws, |
|
|
|
|
workSellAbsUrl: workSellAbsUrl + ws.id + '/', |
|
|
|
|
trunc: _.truncate, |
|
|
|
|
})) |
|
|
|
|
}, res.results) |
|
|
|
|
|
|
|
|
|
if (!res.next) |
|
|
|
|
$moreWorkSellsfBtn.css('display', 'none') |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.loadMorePortfolios = loadMorePortfolios |
|
|
|
|
window.loadMoreWorkSells = loadMoreWorkSells |
|
|
|
|
}()) |
|
|
|
|
</script> |
|
|
|
|
{% endblock %} |
|
|
|
|
|