From 96231331271b1fbc1eca7459f383ed70aa6d0c3d Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Tue, 30 Aug 2016 13:14:01 +0300 Subject: [PATCH] Fixes --- README.md | 8 ++ users/templates/contractor_office.html | 14 +-- users/templates/contractor_profile.html | 118 +++++++++++++----------- 3 files changed, 79 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 5aa803b..c18b63a 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,12 @@ python manage.py generate_reviews ``` +``` +
+
+``` + ---------------------------------------- diff --git a/users/templates/contractor_office.html b/users/templates/contractor_office.html index 6e75308..32e4f32 100644 --- a/users/templates/contractor_office.html +++ b/users/templates/contractor_office.html @@ -163,13 +163,13 @@ @@ -187,18 +187,18 @@ diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 0487231..899da13 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -208,32 +208,30 @@ @@ -310,43 +308,43 @@ {% endfor %} {% endif %} - + ; @@ -567,32 +565,28 @@ 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 portfAbsUrl = '/projects/portfolio/%id%/' // "%id%" will be replaced + var portfEditUrl = '/projects/portfolio/%id%/edit/' + var portfTrashUrl = '/projects/portfolio/%id%/trash/' 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 workSellAbsUrl = '/work_sell/%id%/' + var workSellEditUrl = '/work_sell/%id%/edit/' + var workSellTrashUrl = '/work_sell/%id%/trash/' - var teamId = {{ contractor.team.pk }} - var contractorIds + var contractorId = {{ contractor.pk }} + var authedContractorId{% if request.user.is_authenticated %} = {{ request.user.pk }}{% endif %} 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('user__id', contractorId) portfUrl.setQuery('page_size', pageSize) portfUrl.setQuery('page', query.page ? Number(query.page) + 1 : 2) @@ -601,7 +595,11 @@ _.each(function(portfolio) { $portfoliosContainer.append(portfolioItemTempl({ portfolio: portfolio, - portfAbsUrl: portfAbsUrl + portfolio.id + '/', + portfAbsUrl: _.replace('%id%', portfolio.id, portfAbsUrl), + portfEditUrl: _.replace('%id%', portfolio.id, portfEditUrl), + portfTrashUrl: _.replace('%id%', portfolio.id, portfTrashUrl), + contractorId: contractorId, + authedContractorId: authedContractorId, trunc: _.truncate, })) }, res.results) @@ -618,27 +616,39 @@ function loadMoreWorkSells() { var query = workSellUrl.query(true) - workSellUrl.setQuery('contractor__in', _.join(',', contractorIds)) + workSellUrl.setQuery('contractor__id', contractorId) 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) + $.get(workSellUrl.href()) + .then(function(res) { + _.each(function(ws) { + $workSellsContainer.append(workSellItemTempl({ + workSell: ws, + workSellAbsUrl: _.replace('%id%', ws.id, workSellAbsUrl), + workSellEditUrl: _.replace('%id%', ws.id, workSellEditUrl), + workSellTrashUrl: _.replace('%id%', ws.id, workSellTrashUrl), + contractorId: contractorId, + authedContractorId: authedContractorId, + trunc: _.truncate, + })) + }, res.results) + + if (!res.next) + $moreWorkSellsfBtn.css('display', 'none') + }) - if (!res.next) - $moreWorkSellsfBtn.css('display', 'none') - }) + .then(function() { + $('.open-modal-image').magnificPopup({type: 'image'}) + }) } window.loadMorePortfolios = loadMorePortfolios window.loadMoreWorkSells = loadMoreWorkSells + loadMorePortfolios() + loadMoreWorkSells() + //-----------------------------------------------------------------