diff --git a/archilance/settings/gunicorn.conf.py b/archilance/settings/gunicorn.conf.py new file mode 100644 index 0000000..84788b2 --- /dev/null +++ b/archilance/settings/gunicorn.conf.py @@ -0,0 +1,9 @@ +bind = '127.0.0.1:8046' +workers = 3 +user = "www-data" +reload = True + +try: + from local_gunicorn import * +except ImportError: + pass diff --git a/archilance/urls.py b/archilance/urls.py index 8680ab6..373a2a1 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -15,6 +15,7 @@ urlpatterns = [ url(r'^work_sell/', include('work_sell.urls')), url(r'^test/$', TemplateView.as_view(template_name='test.html'), name='test'), url(r'^projects/', include('projects.urls')), + url(r'^wallets/', include('wallets.urls')), url(r'^chat/', include('chat.urls')), url(r'^specializations/', include('specializations.urls')), url(r'^users/', include('users.urls')), diff --git a/archilance/wsgi.py b/archilance/wsgi.py index 69856cf..1286ecd 100644 --- a/archilance/wsgi.py +++ b/archilance/wsgi.py @@ -11,7 +11,7 @@ from django.core.wsgi import get_wsgi_application from django.template.base import Variable import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archilance.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archilance.settings.prod") application = get_wsgi_application() diff --git a/chat/templates/chat.js b/chat/templates/chat.js index f40e51a..1afb936 100644 --- a/chat/templates/chat.js +++ b/chat/templates/chat.js @@ -1,683 +1,683 @@ - // - // function csrfSafeMethod(method) { - // // these HTTP methods do not require CSRF protection - // return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); - // } - // - // var SocketHandler = function () { - // var userId = {{ request.user.pk }}; - // var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; - // var sock = new WebSocket(url); - // var intervalId; - // sock.onopen = function () { - // console.log("Start connect"); - // intervalId = setInterval(function () { - // sock.send('{"dummy": 1}'); - // }, 150000); - // }; - // sock.onmessage = function (event) { - // console.log(event.data); - // var message = JSON.parse(event.data); - // var inbox; - // - // if (message.answer_type == 'contact' || message.answer_type == 'add_message_contact') { - // inbox = document.getElementById('message-chat-space'); - // } else if (message.answer_type == 'order' || message.answer_type == 'add_message_order') { - // inbox = document.getElementById('message-chat-order-space'); - // } else if(message.answer_type == 'add_message_team'){ - // inbox = document.getElementById('message-chat-team-space'); - // } - // console.log(message.answer_type); - // console.log(message.msg); - // - // inbox.innerHTML += '
' + - // '

ВЫ

13.0.2016
' + - // '

' + message.msg + '

'; - // }; - // - // this.send_contact_message = function (userId) { - // var data = { - // "format_type": "add_message", - // "user_id": userId - // } - // sock.send(JSON.stringify(data)); - // console.log(data); - // }; - // - // this.add_team_message = function(messageData){ - // - // console.log(messageData); - // sock.send(JSON.stringify(messageData)); - // } - // - // this.add_contact_message = function (messageData) { - // console.log(messageData); - // sock.send(JSON.stringify(messageData)); - // }; - // - // this.send_message = function (form) { - // var elements = form.elements; - // var data = {}; - // var i = 0; - // for (var i; i < elements.length; i++) { - // if (elements[i].name == 'message') { - // data[elements[i].name] = elements[i].value; - // } - // } - // sock.send(JSON.stringify(data)); - // var textareaMessage = document.getElementById("message"); - // textareaMessage.value = ""; - // } - // - // } - // - // $(function () { - // var currentChatUser = {{ request.user.pk }}; - // var socket = new SocketHandler(); - // var form = document.getElementById('message_form'); - // var csrftoken = getCookie('csrftoken'); - // - // setTimeout(function(){ - // $(".user-block").first().trigger('click'); - // }, 10); - // - // setTimeout(function(){ - // $(".order-block").first().trigger('click'); - // }, 100); - // - // setTimeout(function(){ - // $(".team-order-block").first().trigger('click'); - // }, 1000); - // - // - // var url = '/work_sell/basic/'; - // $('#upload-document-team').fileupload({ - // url: url, - // crossDomain: false, - // beforeSend: function (xhr, settings) { - // $('#progress .progress-bar').css( - // 'width', - // '0%' - // ); - // if (!csrfSafeMethod(settings.type)) { - // xhr.setRequestHeader("X-CSRFToken", csrftoken); - // } - // }, - // dataType: 'json', - // done: function (e, data) {; - // $.each(data.result.files, function (index, file) { - // var currentValue = $("#documentSendIds").val(); - // currentValue += file.id + ';'; - // $("#documentSendIds").val(currentValue); - // var htmlImg = '

'+ file.name+'

'; - // var document_send = $(htmlImg).appendTo("#document-send"); - // }); - // }, - // progressall: function (e, data) { - // var progress = parseInt(data.loaded / data.total * 100, 10); - // $('#progress .progress-bar').css( - // 'width', - // progress + '%' - // ); - // } - // }).prop('disabled', !$.support.fileInput) - // .parent().addClass($.support.fileInput ? undefined : 'disabled'); - // - // - // $("#approve-stages").on('click', function(){ - // $(".stage-block-approve").each(function(){ - // var stageId = $(this).attr('data-id'); - // }); - // }); - // - // $(".team-chat-user").on('click',function(e){ - // e.stopPropagation(); - // var recipentId = $(this).attr('data-id'); - // $("#team-chat-form #recipentId").val(recipentId); - // }); - // - // $(".team-order-block").on('click', function(){ - // - // $('.team-order-block').each(function () { - // $(this).removeClass('orAct'); - // }); - // $(this).addClass('orAct'); - // - // var teamId = $(this).attr('data-team-id'); - // var orderId = $(this).attr('data-order-id'); - // $("#team-chat-form #teamId").val(teamId); - // $("#team-chat-form #orderId").val(orderId); - // - // var inbox = document.getElementById('message-chat-team-space'); - // inbox.innerHTML = ''; - // - // $.ajax({ - // url: '/api/message', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'team': teamId,'order': orderId}, - // dataType: 'json', - // success: function (json) { - // $.each(json.results, function (i, v) { - // var senderName = 'Вы'; - // var className = 'youChat'; - // if (v.sender.id !== currentChatUser) { - // senderName = v.sender.username; - // className = ''; - // } - // inbox.innerHTML += '
' + - // '

' + senderName + '

' + v.created + '
' + - // '

' + v.text + '

'; - // }); - // } - // }); - // - // }); - // - // // Вытащить сообщения для чата заказа - // $('.order-block').on('click', function () { - // $('.order-block').each(function () { - // $(this).removeClass('orAct'); - // }); - // $(this).addClass('orAct'); - // - // var orderId = $(this).attr('data-id'); - // var recipentId = $(this).attr('data-recipent-id'); - // $("#chat-contractor-order #orderId").val(orderId); - // $("#add-form-order-note #orderNote").val(orderId); - // - // $("#chat-contractor-order #recipentOrderId").val(recipentId); - // $("#add-form-order-note #recipentNote").val(recipentId); - // - // var inbox = document.getElementById('message-chat-order-space'); - // inbox.innerHTML = ''; - // - // $.ajax({ - // url: '/api/message', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - // dataType: 'json', - // success: function (json) { - // $.each(json.results, function (i, v) { - // var senderName = 'Вы'; - // var className = 'youChat'; - // if (v.sender.id !== currentChatUser) { - // senderName = v.sender.username; - // className = ''; - // } - // inbox.innerHTML += '
' + - // '

' + senderName + '

' + v.created + '
' + - // '

' + v.text + '

'; - // }); - // } - // }); - // - // $.ajax({ - // url: '/api/note/', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - // dataType: 'json', - // success: function (json) { - // console.log(json.results); - // var noteHtmlInbox = ''; - // $.each(json.results, function (i, v) { - // noteHtmlInbox += '
  • '+ v.text +'
  • '; - // - // }); - // $(".notes-block").html(noteHtmlInbox); - // } - // }); - // - // $.ajax({ - // url: '/api/stages/', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - // dataType: 'json', - // success: function (json) { - // console.log(json.results); - // var htmlInbox = ""; - // var stagesReservedHtml = ""; - // if (json.results.length > 0) { - // - // $.each(json.results, function (i, v) { - // if(v.is_paid){ - // stagesReservedHtml += '
  • Сумма за этап '+ i +'.Зарезервирована.
  • '; - // }else{ - // stagesReservedHtml += '
  • Сумма за этап '+ i +'.Не зарезервирована.
  • '; - // } - // htmlInbox += '
    ' + - // '

    Этап ' + v.pos + '' + v.name + '

    ' + - // '

    Результаты этапа:' + v.result + '

    ' + - // '

    '+ v.status+'

    ' + v.cost + '
    '; - // }); - // htmlInbox += '
    согласовать
    '; - // - // } - // $("#order-stages").html(htmlInbox); - // $(".stages-paid").html(stagesReservedHtml); - // - // } - // }); - // - // }); - // - // $('#add-note-button').on('click', function(){ - // $.ajax({ - // url: '/api/note/', - // type: 'POST', - // beforeSend: function (xhr) { - // xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) - // }, - // data:$("#add-form-order-note").serialize(), - // dataType: 'json', - // success: function (json) { - // console.log(json); - // $("#add-form-order-note #chat2").val(""); - // - // }, - // error: function(e){ - // console.log('error'); - // console.log(e); - // } - // }); - // }); - // - // // Вытащить сообщения для конактов - // $('.user-block').on('click', function () { - // var userId = $(this).attr('data-id'); - // $("#contact-chat-form #recipentId").val(userId); - // var inbox = document.getElementById('message-chat-space'); - // inbox.innerHTML = ''; - // $.ajax({ - // url: '/api/message', - // type: 'GET', - // data: { - // csrfmiddlewaretoken: csrftoken, - // 'operand': 'in', - // 'sender_id': currentChatUser, - // 'recipent_id': userId - // }, - // dataType: 'json', - // success: function (json) { - // $.each(json.results, function (i, v) { - // console.log(v.sender.id); - // var senderName = 'Вы'; - // var className = 'youChat'; - // if (v.sender.id == userId) { - // senderName = v.sender.username; - // className = ''; - // } - // inbox.innerHTML += '
    ' + - // '

    ' + senderName + '

    ' + v.created + '
    ' + - // '

    ' + v.text + '

    '; - // }); - // } - // }); - // - // }); - // - // //Добавить сообщение для исполнителей в группе - // $("#add-team-chat-message").on('click', function(){ - // var chatMessage = $("#team-chat-form #chatText").val(); - // var recipentId = $("#team-chat-form #recipentId").val(); - // var senderId = $("#team-chat-form #senderId").val(); - // var teamId = $("#team-chat-form #teamId").val(); - // var orderId = $("#team-chat-form #orderId").val(); - // - // var documentSendIds = $("#documentSendIds").val(); - // console.log(documentSendIds); - // var teamDocumentIds = documentSendIds.split(';'); - // teamDocumentIds.pop(); - // console.log(teamDocumentIds); - // socket.add_team_message({ - // "format_type": "add_message_team", - // "data": { - // "sender_id": senderId, - // "recipent_id": recipentId, - // "chat_message": chatMessage, - // "team_id": teamId, - // "order_id": orderId, - // } - // }); - // - // - // - // $("#team-chat-form #chatText").val(""); - // }); - // - // // Добавить сообщение для контакта - // $('#contact-chat-add-message').on('click', function () { - // var chatMessage = $("#chat").val(); - // var recipentId = $("#recipentId").val(); - // var senderId = $("#senderId").val(); - // - // socket.add_contact_message({ - // "format_type": "add_message_contact", - // "data": { - // "sender_id": senderId, - // "recipent_id": recipentId, - // "chat_message": chatMessage, - // } - // }); - // - // var inbox = $('#message-chat-space').html(); - // $('#message-chat-space').html(inbox + '
    ' + - // '

    Вы

    Сейчас
    ' + - // '

    ' + chatMessage + '

    '); - // - // $("#chat").val(""); - // }); - // - // $('#order-chat-add-message').on('click', function () { - // var chatMessage = $("#chat-contractor-order #chat").val(); - // var recipentId = $("#chat-contractor-order #recipentOrderId").val(); - // var senderId = $("#chat-contractor-order #senderOrderId").val(); - // var orderId = $("#chat-contractor-order #orderId").val(); - // - // socket.add_contact_message({ - // "format_type": "add_message_order", - // "data": { - // "sender_id": senderId, - // "recipent_id": recipentId, - // "chat_message": chatMessage, - // "order_id": orderId, - // - // } - // }); - // - // $("#chat-contractor-order #chat").val(""); - // - // }); - // - // }); - // - // - //$(function () { - // var currentChatUser = {{ request.user.pk }}; - // var socket = new SocketHandler(); - // var form = document.getElementById('message_form'); - // var csrftoken = getCookie('csrftoken'); - // setTimeout(function(){ - // $(".user-block").first().trigger('click'); - // }, 10); - // - // setTimeout(function(){ - // $(".order-block").first().trigger('click'); - // }, 100); - // - // $("#order-stages").on('click', "#addStagesForm", function(){ - // $(".new-stages-form").each(function(i,v){ - // console.log($(this).serialize()); - // alert($(this).serialize()); - // - // $.ajax({ - // url: '/api/stages/', - // type: 'POST', - // beforeSend: function (xhr) { - // xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) - // }, - // data:$(this).serialize(), - // dataType: 'json', - // success: function (json) { - // console.log(json); - // }, - // error: function(e){ - // console.log('error'); - // console.log(e); - // } - // }); - // - // }); - // }); - // - // $('#order-stages-tab').on('change', '#countStage', function(){ - // var countStage = parseInt($(this).val()); - // var updateFormStages = $(".update-stages-form"); - // - // alert(updateFormStages.length); - // alert(typeof updateFormStages.length); - // var limitCount = countStage + 1; - // for (var i = 2; i < limitCount; i++) { - // var stageCopy = $("#stage1").clone().attr("id", "stage" + i).addClass("stages_form"); - // $("#stage1").after(stageCopy); - // } - // }); - // - // $('.order-block').on('click', function () { - // $("#chat-order-add").css("display", "block"); - // $("#formsetStage").css("display","block"); - // - // $('.order-block').each(function () { - // $(this).removeClass('orAct'); - // }); - // - // $(this).addClass('orAct'); - // var orderId = $(this).attr('data-id'); - // var recipentId = $(this).attr('data-recipent-id'); - // $("#chat-order-add #orderId").val(orderId); - // $("#chat-order-add #recipentId").val(recipentId); - // $(".orderStagesInput").val(orderId); - // var inbox = document.getElementById('message-chat-order-space'); - // inbox.innerHTML = ''; - // $.ajax({ - // url: '/api/message', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - // dataType: 'json', - // success: function (json) { - // $.each(json.results, function (i, v) { - // var senderName = 'Вы'; - // var className = 'youChat'; - // - // if (v.sender.id !== currentChatUser) { - // senderName = v.sender.username; - // className = ''; - // } - // - // inbox.innerHTML += '
    ' + - // '

    ' + senderName + '

    ' + v.created + '
    ' + - // '

    ' + v.text + '

    '; - // }); - // } - // }); - // - // $.ajax({ - // url: '/api/stages/', - // type: 'GET', - // data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - // dataType: 'json', - // success: function (json) { - // var stageCount = json.results.length; - // if (stageCount == 0){ - // stageCountVal = 1; - // }else{ - // stageCountVal = stageCount; - // } - // - // var htmlInbox = ""; - // - // var htmlInboxStage = '

    Какое кол-во этапов подразумевает работа? ' + - // '

    '; - // - // if (stageCount == 0){ - // htmlInboxStage += '
    ' + - // '

    Этап 1

    ' + - // '' + - // '' + - // ' />' + - // '' + - // '' + - // '
    '; - // } - // var statusNotAgreed = true; - // $.each(json.results, function (i, v) { - // if (v.status == "not_agreed") { - // htmlInbox += '
    ' + - // '

    Этап

    ' + - // '' + - // '' + - // '' + - // '' + - // '' + - // '
    '; - // } else { - // statusNotAgreed = false; - // htmlInboxStage = ""; - // htmlInbox += '
    ' + - // '

    Этап ' + v.pos + '' + v.name + '

    ' + - // '

    Результаты этапа:' + v.result + '

    ' + - // '

    до 16.03.2015

    ' + v.cost + '
    '; - // - // } - // }); - // - // if (statusNotAgreed) { - // htmlInbox += '
    Перейти в режим безопасной сделки' + - // '
    ' + - // 'отправить на согласование
    '; - // } - // htmlInbox = htmlInboxStage + htmlInbox; - // $("#order-stages").html(htmlInbox); - // } - // }); - // - // - // }); - // - // // Вытащить сообщения для конактов - // $('.user-block').on('click', function () { - // var userId = $(this).attr('data-id'); - // $("#contact-chat-form #recipentId").val(userId); - // var inbox = document.getElementById('message-chat-space'); - // inbox.innerHTML = ''; - // $.ajax({ - // url: '/api/message', - // type: 'GET', - // data: { - // csrfmiddlewaretoken: csrftoken, - // 'operand': 'in', - // 'sender_id': currentChatUser, - // 'recipent_id': userId - // }, - // dataType: 'json', - // success: function (json) { - // $.each(json.results, function (i, v) { - // var senderName = 'Вы'; - // var className = 'youChat'; - // if (v.sender.id == userId) { - // senderName = v.sender.username; - // className = ''; - // } - // inbox.innerHTML += '
    ' + - // '

    ' + senderName + '

    ' + v.created + '
    ' + - // '

    ' + v.text + '

    '; - // }); - // } - // }); - // - // }); - // - // $('#contact-chat-add-message').on('click', function () { - // var chatMessage = $("#chat").val(); - // var recipentId = $("#recipentId").val(); - // var senderId = $("#senderId").val(); - // - // socket.add_contact_message({ - // "format_type": "add_message_contact", - // "data": { - // "sender_id": senderId, - // "recipent_id": recipentId, - // "chat_message": chatMessage, - // } - // }); - // - // $("#chat").val(""); - // }); - // - // $('#order-chat-add-message').on('click', function () { - // var chatMessage = $("#chat-order-add #chat").val(); - // var recipentId = $("#chat-order-add #recipentId").val(); - // var senderId = $("#chat-order-add #senderId").val(); - // var orderId = $("#chat-order-add #orderId").val(); - // - // socket.add_contact_message({ - // "format_type": "add_message_order", - // "data": { - // "sender_id": senderId, - // "recipent_id": recipentId, - // "chat_message": chatMessage, - // "order_id": orderId, - // - // } - // }); - // - // $("#chat-order-add #chat").val(""); - // }); - // - // }); - // - // var userId = '{{ request.user.pk }}'; - // - // var SocketHandler = function () { - // var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; - // var sock = new WebSocket(url); - // var intervalId; - // sock.onopen = function () { - // console.log("Start connect"); - // intervalId = setInterval(function () { - // sock.send('{"dummy": 1}'); - // }, 150); - // }; - // sock.onmessage = function (event) { - // console.log(event.data); - // var message = JSON.parse(event.data); - // var inbox; - // if (message.answer_type == 'contact') { - // inbox = document.getElementById('message-chat-space'); - // } else if (message.answer_type == 'order' || message.answer_type == 'add_order') { - // inbox = document.getElementById('message-chat-order-space') - // } - // inbox.innerHTML += '
    ' + - // '

    Иванов

    13.0.2016
    ' + - // '

    ' + message.msg + '

    '; - // - // }; - // - // this.send_order_message = function (orderId) { - // var data = { - // "format_type": "order_message", - // "order_id": orderId - // } - // sock.send(JSON.stringify(data)); - // console.log(data); - // }; - // - // this.send_contact_message = function (userId) { - // var data = { - // "format_type": "add_message", - // "user_id": userId - // } - // sock.send(JSON.stringify(data)); - // console.log(data); - // }; - // - // this.add_contact_message = function (messageData) { - // console.log(messageData); - // sock.send(JSON.stringify(messageData)); - // }; - // - // this.send_message = function (form) { - // var elements = form.elements; - // var data = {}; - // var i = 0; - // for (var i; i < elements.length; i++) { - // if (elements[i].name == 'message') { - // data[elements[i].name] = elements[i].value; - // } - // } - // sock.send(JSON.stringify(data)); - // var textareaMessage = document.getElementById("message"); - // textareaMessage.value = ""; - // - // } - // } - // + + function csrfSafeMethod(method) { + // these HTTP methods do not require CSRF protection + return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); + } + + var SocketHandler = function () { + var userId = {{ request.user.pk }}; + var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; + var sock = new WebSocket(url); + var intervalId; + sock.onopen = function () { + console.log("Start connect"); + intervalId = setInterval(function () { + sock.send('{"dummy": 1}'); + }, 150000); + }; + sock.onmessage = function (event) { + console.log(event.data); + var message = JSON.parse(event.data); + var inbox; + + if (message.answer_type == 'contact' || message.answer_type == 'add_message_contact') { + inbox = document.getElementById('message-chat-space'); + } else if (message.answer_type == 'order' || message.answer_type == 'add_message_order') { + inbox = document.getElementById('message-chat-order-space'); + } else if(message.answer_type == 'add_message_team'){ + inbox = document.getElementById('message-chat-team-space'); + } + console.log(message.answer_type); + console.log(message.msg); + + inbox.innerHTML += '
    ' + + '

    ВЫ

    13.0.2016
    ' + + '

    ' + message.msg + '

    '; + }; + + this.send_contact_message = function (userId) { + var data = { + "format_type": "add_message", + "user_id": userId + } + sock.send(JSON.stringify(data)); + console.log(data); + }; + + this.add_team_message = function(messageData){ + + console.log(messageData); + sock.send(JSON.stringify(messageData)); + } + + this.add_contact_message = function (messageData) { + console.log(messageData); + sock.send(JSON.stringify(messageData)); + }; + + this.send_message = function (form) { + var elements = form.elements; + var data = {}; + var i = 0; + for (var i; i < elements.length; i++) { + if (elements[i].name == 'message') { + data[elements[i].name] = elements[i].value; + } + } + sock.send(JSON.stringify(data)); + var textareaMessage = document.getElementById("message"); + textareaMessage.value = ""; + } + + } + + $(function () { + var currentChatUser = {{ request.user.pk }}; + var socket = new SocketHandler(); + var form = document.getElementById('message_form'); + var csrftoken = getCookie('csrftoken'); + + setTimeout(function(){ + $(".user-block").first().trigger('click'); + }, 10); + + setTimeout(function(){ + $(".order-block").first().trigger('click'); + }, 100); + + setTimeout(function(){ + $(".team-order-block").first().trigger('click'); + }, 1000); + + + var url = '/work_sell/basic/'; + $('#upload-document-team').fileupload({ + url: url, + crossDomain: false, + beforeSend: function (xhr, settings) { + $('#progress .progress-bar').css( + 'width', + '0%' + ); + if (!csrfSafeMethod(settings.type)) { + xhr.setRequestHeader("X-CSRFToken", csrftoken); + } + }, + dataType: 'json', + done: function (e, data) {; + $.each(data.result.files, function (index, file) { + var currentValue = $("#documentSendIds").val(); + currentValue += file.id + ';'; + $("#documentSendIds").val(currentValue); + var htmlImg = '

    '+ file.name+'

    '; + var document_send = $(htmlImg).appendTo("#document-send"); + }); + }, + progressall: function (e, data) { + var progress = parseInt(data.loaded / data.total * 100, 10); + $('#progress .progress-bar').css( + 'width', + progress + '%' + ); + } + }).prop('disabled', !$.support.fileInput) + .parent().addClass($.support.fileInput ? undefined : 'disabled'); + + + $("#approve-stages").on('click', function(){ + $(".stage-block-approve").each(function(){ + var stageId = $(this).attr('data-id'); + }); + }); + + $(".team-chat-user").on('click',function(e){ + e.stopPropagation(); + var recipentId = $(this).attr('data-id'); + $("#team-chat-form #recipentId").val(recipentId); + }); + + $(".team-order-block").on('click', function(){ + + $('.team-order-block').each(function () { + $(this).removeClass('orAct'); + }); + $(this).addClass('orAct'); + + var teamId = $(this).attr('data-team-id'); + var orderId = $(this).attr('data-order-id'); + $("#team-chat-form #teamId").val(teamId); + $("#team-chat-form #orderId").val(orderId); + + var inbox = document.getElementById('message-chat-team-space'); + inbox.innerHTML = ''; + + $.ajax({ + url: '/api/message', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'team': teamId,'order': orderId}, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + var senderName = 'Вы'; + var className = 'youChat'; + if (v.sender.id !== currentChatUser) { + senderName = v.sender.username; + className = ''; + } + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + }); + + // Вытащить сообщения для чата заказа + $('.order-block').on('click', function () { + $('.order-block').each(function () { + $(this).removeClass('orAct'); + }); + $(this).addClass('orAct'); + + var orderId = $(this).attr('data-id'); + var recipentId = $(this).attr('data-recipent-id'); + $("#chat-contractor-order #orderId").val(orderId); + $("#add-form-order-note #orderNote").val(orderId); + + $("#chat-contractor-order #recipentOrderId").val(recipentId); + $("#add-form-order-note #recipentNote").val(recipentId); + + var inbox = document.getElementById('message-chat-order-space'); + inbox.innerHTML = ''; + + $.ajax({ + url: '/api/message', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + var senderName = 'Вы'; + var className = 'youChat'; + if (v.sender.id !== currentChatUser) { + senderName = v.sender.username; + className = ''; + } + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + $.ajax({ + url: '/api/note/', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + console.log(json.results); + var noteHtmlInbox = ''; + $.each(json.results, function (i, v) { + noteHtmlInbox += '
  • '+ v.text +'
  • '; + + }); + $(".notes-block").html(noteHtmlInbox); + } + }); + + $.ajax({ + url: '/api/stages/', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + console.log(json.results); + var htmlInbox = ""; + var stagesReservedHtml = ""; + if (json.results.length > 0) { + + $.each(json.results, function (i, v) { + if(v.is_paid){ + stagesReservedHtml += '
  • Сумма за этап '+ i +'.Зарезервирована.
  • '; + }else{ + stagesReservedHtml += '
  • Сумма за этап '+ i +'.Не зарезервирована.
  • '; + } + htmlInbox += '
    ' + + '

    Этап ' + v.pos + '' + v.name + '

    ' + + '

    Результаты этапа:' + v.result + '

    ' + + '

    '+ v.status+'

    ' + v.cost + '
    '; + }); + htmlInbox += '
    согласовать
    '; + + } + $("#order-stages").html(htmlInbox); + $(".stages-paid").html(stagesReservedHtml); + + } + }); + + }); + + $('#add-note-button').on('click', function(){ + $.ajax({ + url: '/api/note/', + type: 'POST', + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data:$("#add-form-order-note").serialize(), + dataType: 'json', + success: function (json) { + console.log(json); + $("#add-form-order-note #chat2").val(""); + + }, + error: function(e){ + console.log('error'); + console.log(e); + } + }); + }); + + // Вытащить сообщения для конактов + $('.user-block').on('click', function () { + var userId = $(this).attr('data-id'); + $("#contact-chat-form #recipentId").val(userId); + var inbox = document.getElementById('message-chat-space'); + inbox.innerHTML = ''; + $.ajax({ + url: '/api/message', + type: 'GET', + data: { + csrfmiddlewaretoken: csrftoken, + 'operand': 'in', + 'sender_id': currentChatUser, + 'recipent_id': userId + }, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + console.log(v.sender.id); + var senderName = 'Вы'; + var className = 'youChat'; + if (v.sender.id == userId) { + senderName = v.sender.username; + className = ''; + } + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + }); + + //Добавить сообщение для исполнителей в группе + $("#add-team-chat-message").on('click', function(){ + var chatMessage = $("#team-chat-form #chatText").val(); + var recipentId = $("#team-chat-form #recipentId").val(); + var senderId = $("#team-chat-form #senderId").val(); + var teamId = $("#team-chat-form #teamId").val(); + var orderId = $("#team-chat-form #orderId").val(); + + var documentSendIds = $("#documentSendIds").val(); + console.log(documentSendIds); + var teamDocumentIds = documentSendIds.split(';'); + teamDocumentIds.pop(); + console.log(teamDocumentIds); + socket.add_team_message({ + "format_type": "add_message_team", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + "team_id": teamId, + "order_id": orderId, + } + }); + + + + $("#team-chat-form #chatText").val(""); + }); + + // Добавить сообщение для контакта + $('#contact-chat-add-message').on('click', function () { + var chatMessage = $("#chat").val(); + var recipentId = $("#recipentId").val(); + var senderId = $("#senderId").val(); + + socket.add_contact_message({ + "format_type": "add_message_contact", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + } + }); + + var inbox = $('#message-chat-space').html(); + $('#message-chat-space').html(inbox + '
    ' + + '

    Вы

    Сейчас
    ' + + '

    ' + chatMessage + '

    '); + + $("#chat").val(""); + }); + + $('#order-chat-add-message').on('click', function () { + var chatMessage = $("#chat-contractor-order #chat").val(); + var recipentId = $("#chat-contractor-order #recipentOrderId").val(); + var senderId = $("#chat-contractor-order #senderOrderId").val(); + var orderId = $("#chat-contractor-order #orderId").val(); + + socket.add_contact_message({ + "format_type": "add_message_order", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + "order_id": orderId, + + } + }); + + $("#chat-contractor-order #chat").val(""); + + }); + + }); + + + $(function () { + var currentChatUser = {{ request.user.pk }}; + var socket = new SocketHandler(); + var form = document.getElementById('message_form'); + var csrftoken = getCookie('csrftoken'); + setTimeout(function(){ + $(".user-block").first().trigger('click'); + }, 10); + + setTimeout(function(){ + $(".order-block").first().trigger('click'); + }, 100); + + $("#order-stages").on('click', "#addStagesForm", function(){ + $(".new-stages-form").each(function(i,v){ + console.log($(this).serialize()); + alert($(this).serialize()); + + $.ajax({ + url: '/api/stages/', + type: 'POST', + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data:$(this).serialize(), + dataType: 'json', + success: function (json) { + console.log(json); + }, + error: function(e){ + console.log('error'); + console.log(e); + } + }); + + }); + }); + + $('#order-stages-tab').on('change', '#countStage', function(){ + var countStage = parseInt($(this).val()); + var updateFormStages = $(".update-stages-form"); + + alert(updateFormStages.length); + alert(typeof updateFormStages.length); + var limitCount = countStage + 1; + for (var i = 2; i < limitCount; i++) { + var stageCopy = $("#stage1").clone().attr("id", "stage" + i).addClass("stages_form"); + $("#stage1").after(stageCopy); + } + }); + + $('.order-block').on('click', function () { + $("#chat-order-add").css("display", "block"); + $("#formsetStage").css("display","block"); + + $('.order-block').each(function () { + $(this).removeClass('orAct'); + }); + + $(this).addClass('orAct'); + var orderId = $(this).attr('data-id'); + var recipentId = $(this).attr('data-recipent-id'); + $("#chat-order-add #orderId").val(orderId); + $("#chat-order-add #recipentId").val(recipentId); + $(".orderStagesInput").val(orderId); + var inbox = document.getElementById('message-chat-order-space'); + inbox.innerHTML = ''; + $.ajax({ + url: '/api/message', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + var senderName = 'Вы'; + var className = 'youChat'; + + if (v.sender.id !== currentChatUser) { + senderName = v.sender.username; + className = ''; + } + + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + $.ajax({ + url: '/api/stages/', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + var stageCount = json.results.length; + if (stageCount == 0){ + stageCountVal = 1; + }else{ + stageCountVal = stageCount; + } + + var htmlInbox = ""; + + var htmlInboxStage = '

    Какое кол-во этапов подразумевает работа? ' + + '

    '; + + if (stageCount == 0){ + htmlInboxStage += '
    ' + + '

    Этап 1

    ' + + '' + + '' + + ' />' + + '' + + '' + + '
    '; + } + var statusNotAgreed = true; + $.each(json.results, function (i, v) { + if (v.status == "not_agreed") { + htmlInbox += '
    ' + + '

    Этап

    ' + + '' + + '' + + '' + + '' + + '' + + '
    '; + } else { + statusNotAgreed = false; + htmlInboxStage = ""; + htmlInbox += '
    ' + + '

    Этап ' + v.pos + '' + v.name + '

    ' + + '

    Результаты этапа:' + v.result + '

    ' + + '

    до 16.03.2015

    ' + v.cost + '
    '; + + } + }); + + if (statusNotAgreed) { + htmlInbox += '
    Перейти в режим безопасной сделки' + + '
    ' + + 'отправить на согласование
    '; + } + htmlInbox = htmlInboxStage + htmlInbox; + $("#order-stages").html(htmlInbox); + } + }); + + + }); + + // Вытащить сообщения для конактов + $('.user-block').on('click', function () { + var userId = $(this).attr('data-id'); + $("#contact-chat-form #recipentId").val(userId); + var inbox = document.getElementById('message-chat-space'); + inbox.innerHTML = ''; + $.ajax({ + url: '/api/message', + type: 'GET', + data: { + csrfmiddlewaretoken: csrftoken, + 'operand': 'in', + 'sender_id': currentChatUser, + 'recipent_id': userId + }, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + var senderName = 'Вы'; + var className = 'youChat'; + if (v.sender.id == userId) { + senderName = v.sender.username; + className = ''; + } + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + }); + + $('#contact-chat-add-message').on('click', function () { + var chatMessage = $("#chat").val(); + var recipentId = $("#recipentId").val(); + var senderId = $("#senderId").val(); + + socket.add_contact_message({ + "format_type": "add_message_contact", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + } + }); + + $("#chat").val(""); + }); + + $('#order-chat-add-message').on('click', function () { + var chatMessage = $("#chat-order-add #chat").val(); + var recipentId = $("#chat-order-add #recipentId").val(); + var senderId = $("#chat-order-add #senderId").val(); + var orderId = $("#chat-order-add #orderId").val(); + + socket.add_contact_message({ + "format_type": "add_message_order", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + "order_id": orderId, + + } + }); + + $("#chat-order-add #chat").val(""); + }); + + }); + + var userId = '{{ request.user.pk }}'; + + var SocketHandler = function () { + var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; + var sock = new WebSocket(url); + var intervalId; + sock.onopen = function () { + console.log("Start connect"); + intervalId = setInterval(function () { + sock.send('{"dummy": 1}'); + }, 150); + }; + sock.onmessage = function (event) { + console.log(event.data); + var message = JSON.parse(event.data); + var inbox; + if (message.answer_type == 'contact') { + inbox = document.getElementById('message-chat-space'); + } else if (message.answer_type == 'order' || message.answer_type == 'add_order') { + inbox = document.getElementById('message-chat-order-space') + } + inbox.innerHTML += '
    ' + + '

    Иванов

    13.0.2016
    ' + + '

    ' + message.msg + '

    '; + + }; + + this.send_order_message = function (orderId) { + var data = { + "format_type": "order_message", + "order_id": orderId + } + sock.send(JSON.stringify(data)); + console.log(data); + }; + + this.send_contact_message = function (userId) { + var data = { + "format_type": "add_message", + "user_id": userId + } + sock.send(JSON.stringify(data)); + console.log(data); + }; + + this.add_contact_message = function (messageData) { + console.log(messageData); + sock.send(JSON.stringify(messageData)); + }; + + this.send_message = function (form) { + var elements = form.elements; + var data = {}; + var i = 0; + for (var i; i < elements.length; i++) { + if (elements[i].name == 'message') { + data[elements[i].name] = elements[i].value; + } + } + sock.send(JSON.stringify(data)); + var textareaMessage = document.getElementById("message"); + textareaMessage.value = ""; + + } + } + diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index 296a404..5f8f066 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -237,6 +237,69 @@ var socket = new SocketHandler(); var form = document.getElementById('message_form'); var csrftoken = getCookie('csrftoken'); + + function getStages(orderId){ + + $.ajax({ + url: '/api/stages/', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + var stageCount = json.results.length; + if (stageCount == 0){ + stageCountVal = 1; + }else{ + stageCountVal = stageCount; + } + + var htmlInbox = ""; + + var htmlInboxStage = '

    Какое кол-во этапов подразумевает работа? ' + + '

    '; + + if (stageCount == 0){ + htmlInboxStage += '
    ' + + '

    Этап 1

    ' + + '' + + '' + + ' />' + + '' + + '' + + '
    '; + } + var statusNotAgreed = true; + $.each(json.results, function (i, v) { + if (v.status == "not_agreed") { + htmlInbox += '
    ' + + '

    Этап

    ' + + '' + + '' + + '' + + '' + + '' + + '
    '; + } else { + statusNotAgreed = false; + htmlInboxStage = ""; + htmlInbox += '
    ' + + '

    Этап ' + v.pos + '' + v.name + '

    ' + + '

    Результаты этапа:' + v.result + '

    ' + + '

    до 16.03.2015

    ' + v.cost + '
    '; + + } + }); + + if (statusNotAgreed) { + htmlInbox += '
    Перейти в режим безопасной сделки' + + '
    ' + + 'отправить на согласование
    '; + } + htmlInbox = htmlInboxStage + htmlInbox; + $("#order-stages").html(htmlInbox); + } + }); + } setTimeout(function(){ $(".user-block").first().trigger('click'); }, 10); @@ -245,10 +308,10 @@ $(".order-block").first().trigger('click'); }, 100); - $("#order-stages").on('click', "#addStagesForm", function(){ + $("#order-stages").on('click', "#addStagesForm", function(e){ + e.preventDefault(); $(".new-stages-form").each(function(i,v){ console.log($(this).serialize()); - alert($(this).serialize()); $.ajax({ url: '/api/stages/', @@ -260,6 +323,7 @@ dataType: 'json', success: function (json) { console.log(json); + }, error: function(e){ console.log('error'); @@ -268,14 +332,41 @@ }); }); + + $(".update-stages-form").each(function(i,v){ + var currentStageId = parseInt($(this).attr('data-order-id')); + alert(currentStageId); + $.ajax({ + url: '/api/stages/' + currentStageId + '/', + type: 'PUT', + beforeSend: function(xhr){ + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data: $(this).serialize(), + dataType:'json', + success: function(json){ + console.log(json); + }, + error: function(e){ + console.log('error'); + console.log(e); + } + }); + }); + + + + + var currentOrderId = $(this).attr('data-order-id'); + currentOrderId = parseInt(currentOrderId); + getStages(currentOrderId); + + }); $('#order-stages-tab').on('change', '#countStage', function(){ var countStage = parseInt($(this).val()); var updateFormStages = $(".update-stages-form"); - - alert(updateFormStages.length); - alert(typeof updateFormStages.length); var limitCount = countStage + 1; for (var i = 2; i < limitCount; i++) { var stageCopy = $("#stage1").clone().attr("id", "stage" + i).addClass("stages_form"); @@ -321,65 +412,67 @@ } }); - $.ajax({ - url: '/api/stages/', - type: 'GET', - data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - dataType: 'json', - success: function (json) { - var stageCount = json.results.length; - if (stageCount == 0){ - stageCountVal = 1; - }else{ - stageCountVal = stageCount; - } - - var htmlInbox = ""; - - var htmlInboxStage = '

    Какое кол-во этапов подразумевает работа? ' + - '

    '; - - if (stageCount == 0){ - htmlInboxStage += '
    ' + - '

    Этап 1

    ' + - '' + - '' + - ' />' + - '' + - '' + - '
    '; - } - var statusNotAgreed = true; - $.each(json.results, function (i, v) { - if (v.status == "not_agreed") { - htmlInbox += '
    ' + - '

    Этап

    ' + - '' + - '' + - '' + - '' + - '' + - '
    '; - } else { - statusNotAgreed = false; - htmlInboxStage = ""; - htmlInbox += '
    ' + - '

    Этап ' + v.pos + '' + v.name + '

    ' + - '

    Результаты этапа:' + v.result + '

    ' + - '

    до 16.03.2015

    ' + v.cost + '
    '; - - } - }); - - if (statusNotAgreed) { - htmlInbox += '
    Перейти в режим безопасной сделки' + - '
    ' + - 'отправить на согласование
    '; - } - htmlInbox = htmlInboxStage + htmlInbox; - $("#order-stages").html(htmlInbox); - } - }); + getStages(orderId); + +{# $.ajax({#} +{# url: '/api/stages/',#} +{# type: 'GET',#} +{# data: {csrfmiddlewaretoken: csrftoken, 'order': orderId},#} +{# dataType: 'json',#} +{# success: function (json) {#} +{# var stageCount = json.results.length;#} +{# if (stageCount == 0){#} +{# stageCountVal = 1;#} +{# }else{#} +{# stageCountVal = stageCount;#} +{# }#} +{##} +{# var htmlInbox = "";#} +{##} +{# var htmlInboxStage = '

    Какое кол-во этапов подразумевает работа? ' +#} +{# '

    ';#} +{##} +{# if (stageCount == 0){#} +{# htmlInboxStage += '
    ' +#} +{# '

    Этап 1

    ' +#} +{# '' +#} +{# '' +#} +{# ' />' +#} +{# '' +#} +{# '' +#} +{# '
    ';#} +{# }#} +{# var statusNotAgreed = true;#} +{# $.each(json.results, function (i, v) {#} +{# if (v.status == "not_agreed") {#} +{# htmlInbox += '
    ' +#} +{# '

    Этап

    ' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '
    ';#} +{# } else {#} +{# statusNotAgreed = false;#} +{# htmlInboxStage = "";#} +{# htmlInbox += '
    ' +#} +{# '

    Этап ' + v.pos + '' + v.name + '

    ' +#} +{# '

    Результаты этапа:' + v.result + '

    ' +#} +{# '

    до 16.03.2015

    ' + v.cost + '
    ';#} +{##} +{# }#} +{# });#} +{##} +{# if (statusNotAgreed) {#} +{# htmlInbox += '
    Перейти в режим безопасной сделки' +#} +{# '
    ' +#} +{# 'отправить на согласование
    ';#} +{# }#} +{# htmlInbox = htmlInboxStage + htmlInbox;#} +{# $("#order-stages").html(htmlInbox);#} +{# }#} +{# });#} }); @@ -456,8 +549,11 @@ }); - var userId = '{{ request.user.pk }}'; + + + + var userId = '{{ request.user.pk }}'; var SocketHandler = function () { var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; var sock = new WebSocket(url); diff --git a/chat/testapp.py b/chat/testapp.py index 8d245d3..fe64028 100644 --- a/chat/testapp.py +++ b/chat/testapp.py @@ -66,7 +66,7 @@ class ChatHandler(websocket.WebSocketHandler): order_value = "NULL" if order_id is None else order_id insert_sql = "INSERT INTO chat_message (id,text,created, sender_id,recipent_id, private_type,team_id, order_id) " \ - "VALUES (DEFAULT,'{0}',NOW(),{1},{2},{3},{4},{5})".format(message, sender_id, recipent_id, private_type, team_value,order_value) + "VALUES (DEFAULT,'{0}',NOW(),{1},{2},{3},{4},{5})".format(message, sender_id, recipent_id, private_type, team_value,order_value) yield self.db.execute(insert_sql) waiters = tuple(w for c, w in self.waiters if c == recipent_id or c == sender_id) diff --git a/chat/views.py b/chat/views.py index 6c1d6d5..6484f04 100644 --- a/chat/views.py +++ b/chat/views.py @@ -12,6 +12,8 @@ class ChatUserView(View): template_name = '' def get(self, request, *args, **kwargs): + # import code; code.interact(local=dict(globals(), **locals())) + user_id = request.GET.get('user_id',None) if request.user.is_authenticated() and request.user.is_customer(): customer_contacts = Message.objects.values_list('sender_id', 'recipent_id'). \ filter(Q(recipent_id=request.user.pk) | Q(sender_id=request.user.pk)).filter(Q(team_id=None)).distinct() @@ -23,6 +25,9 @@ class ChatUserView(View): users_ids.append(a) if b != request.user.pk: users_ids.append(b) + if user_id: + users_ids.append(int(user_id)) + # import code; code.interact(local=dict(globals(), **locals())) contacts_users = User.objects.filter(pk__in=users_ids) chat_messages = Message.objects.filter(Q(sender=request.user.pk) | Q(recipent=request.user.pk)) @@ -42,12 +47,14 @@ class ChatUserView(View): users_ids.append(a) if b != request.user.pk: users_ids.append(b) + if user_id: + users_ids.append(int(user_id)) contacts_users = User.objects.filter(pk__in=users_ids) chat_messages = Message.objects.filter(Q(sender=request.user.pk) | Q(recipent=request.user.pk)).order_by( 'created') if request.user.is_owner_team(): - team_orders = request.user.team.team_orders.all() + team_orders = request.user.team.orders.all() self.template_name = 'chat_contractor.html' return render(request, self.template_name, {'orders': orders, diff --git a/common/migrations/0004_auto_20160808_1557.py b/common/migrations/0004_auto_20160808_1557.py new file mode 100644 index 0000000..7475fcd --- /dev/null +++ b/common/migrations/0004_auto_20160808_1557.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-08 12:57 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0003_auto_20160729_1747'), + ] + + operations = [ + migrations.AddField( + model_name='settings', + name='recalculation_rating_time', + field=models.TimeField(default=datetime.datetime(2016, 8, 8, 12, 57, 41, 160156, tzinfo=utc)), + preserve_default=False, + ), + migrations.AddField( + model_name='settings', + name='recalculation_spec_time', + field=models.TimeField(default=datetime.datetime(2016, 8, 8, 12, 57, 52, 905906, tzinfo=utc)), + preserve_default=False, + ), + ] diff --git a/common/migrations/0005_settings_accountant_send_email.py b/common/migrations/0005_settings_accountant_send_email.py new file mode 100644 index 0000000..01ac195 --- /dev/null +++ b/common/migrations/0005_settings_accountant_send_email.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-09 16:56 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0004_auto_20160808_1557'), + ] + + operations = [ + migrations.AddField( + model_name='settings', + name='accountant_send_email', + field=models.EmailField(default='muhtarzubanchi05@gmail.com', max_length=100), + ), + ] diff --git a/common/models.py b/common/models.py index 95ca414..e05368f 100644 --- a/common/models.py +++ b/common/models.py @@ -38,8 +38,11 @@ class MainPage(models.Model): class Settings(models.Model): time_notification = models.IntegerField(default=180) document_send_email = models.EmailField(max_length=100, default="muhtarzubanchi05@gmail.com") + accountant_send_email = models.EmailField(max_length=100, default="muhtarzubanchi05@gmail.com") document_send_description = models.TextField(blank=True) document_send_time_remove = models.IntegerField(default=14) + recalculation_spec_time = models.TimeField() + recalculation_rating_time = models.TimeField() def __str__(self): return 'Настройки сайта' diff --git a/common/views.py b/common/views.py index 8460409..104893b 100644 --- a/common/views.py +++ b/common/views.py @@ -46,7 +46,7 @@ class PrintDocumentCreate(BaseMixin, View): } - settings = Settings.objects.all().first().doc + settings = Settings.objects.all().first() subject, from_email, to = 'Заявка на распечатку', 'mukhtar@mukhtar', settings.document_send_email text_content = render_to_string('document_email.txt', ctx_dict) html_content = get_template('document_email.html').render(ctx_dict) diff --git a/projects/forms.py b/projects/forms.py index b678c56..2f2bfb0 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -235,6 +235,15 @@ class CustomerProjectTrashForm(forms.Form): self.fields['pk'].queryset = self.req.user.projects.filter(state='active') +class ContractorPortfolioTrashForm(forms.Form): + pk = forms.ModelChoiceField(queryset=Portfolio.objects.none()) + + def __init__(self, *args, **kwargs): + self.request = kwargs.pop('request') + super().__init__(*args, **kwargs) + self.fields['pk'].queryset = self.request.user.portfolios.all() + + class CustomerProjectRestoreForm(forms.Form): pk = forms.ModelChoiceField(queryset=Project.objects.none()) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index dfacf97..d1e8db7 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -1,7 +1,8 @@ {% extends 'partials/base.html' %} {% load humanize %} - +{% load thumbnail %} +{% load specializtions_tags %} {% block content %} {% include 'partials/header.html' %} @@ -314,8 +315,7 @@ {# {% elif request.user.is_contractor and not request.user.contractor_answers.exists %}#} {% if request.user.is_contractor and not request.user.contractor_answers.exists %} - - +
    @@ -418,11 +418,7 @@ {% elif request.user.is_customer %} - - - - - +

    Исполнители

    @@ -452,62 +448,48 @@

    Новые исполнители

    - - - - - - - - - - + + {% for answer_p in project.answers.all %}
    - + {% ratings_widget answer_p.author.pk 'restList2' %} + {% if answer_p.author.cro %}

    Есть допуск СРО

    + {% endif %}

    Цена: - 35 000 + {{ answer_p.budget }}

    - Срок: 3 недели + Срок: {{ answer_p.term }} of {{ answer_p.term_type }}

    -

    Опубликован: 22.04.2016

    +

    Опубликован: {{ answer_p.created | date:"M d, Y" }}

    Кандидат - + предложить проект @@ -548,7 +530,7 @@

    - Иванов Петр Иванович + Иванов Петр Иванович

    13.01.2016 / 21:05 @@ -568,7 +550,7 @@

    - Иванов Петр Иванович + Иванов Петр Иванович

    13.01.2016 / 21:05 @@ -584,6 +566,7 @@
    + {% endfor %} {% endif %} diff --git a/projects/templates/templatetags/ratings_widget.html b/projects/templates/templatetags/ratings_widget.html deleted file mode 100644 index e689a34..0000000 --- a/projects/templates/templatetags/ratings_widget.html +++ /dev/null @@ -1,25 +0,0 @@ -
    - -{##} - diff --git a/projects/templatetags/projects_tags.py b/projects/templatetags/projects_tags.py deleted file mode 100644 index b82c290..0000000 --- a/projects/templatetags/projects_tags.py +++ /dev/null @@ -1,10 +0,0 @@ -from django import template - -register = template.Library() - -@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) -def ratings_widget(context, user_id, class_name=None): - ratings = user_id - return { - 'ratings': ratings, - } diff --git a/projects/urls.py b/projects/urls.py index 4e3a9b1..c16f654 100644 --- a/projects/urls.py +++ b/projects/urls.py @@ -14,6 +14,7 @@ from .views import ( ProjectComparisonView, ProjectFilterView, ProjectDetailWithContractorAnswerView, + ContractorPortfolioTrashView, ) app_name = 'projects' @@ -25,6 +26,7 @@ urlpatterns = [ urls.url(r'^create/$', CustomerProjectCreateView.as_view(), name='customer-project-create'), urls.url(r'^(?P\d+)/edit/$', CustomerProjectEditView.as_view(), name='customer-project-edit'), urls.url(r'^(?P\d+)/trash/$', CustomerProjectTrashView.as_view(), name='customer-project-trash'), + urls.url(r'^portfolio/(?P\d+)/trash/$', ContractorPortfolioTrashView.as_view(), name='contractor-portfolio-trash'), urls.url(r'^(?P\d+)/restore/$', CustomerProjectRestoreView.as_view(), name='customer-project-restore'), urls.url(r'^(?P\d+)/delete/$', CustomerProjectDeleteView.as_view(), name='customer-project-delete'), diff --git a/projects/views.py b/projects/views.py index f3f5f7d..86a98fb 100644 --- a/projects/views.py +++ b/projects/views.py @@ -15,7 +15,7 @@ import pydash as _; _.map = _.map_; _.filter = _.filter_ import re from .mixins import LastAccessMixin -from .models import Project, ProjectFile, Portfolio, Candidate, Answer, AnswerFile, Realty, Order +from .models import Project, ProjectFile, Portfolio, PortfolioPhoto,Candidate, Answer, AnswerFile, Realty, Order from archilance.mixins import BaseMixin from users.models import User from work_sell.models import Picture @@ -31,6 +31,7 @@ from .forms import ( ProjectFilterForm, ProjectFilterRealtyForm, RealtyForm, + ContractorPortfolioTrashForm, ) @@ -176,7 +177,7 @@ class ProjectFilterView(BaseMixin, View): '
    {realty_form}
    ' ).format(realty_form=pformat(realty_form.errors))) - + # import code; code.interact(local=dict(globals(), **locals())) paginator = Paginator(projects.all(), settings.PAGE_SIZE) page = request.GET.get('page') @@ -355,6 +356,21 @@ class CustomerProjectEditView(BaseMixin, View): return render(request, self.template_name, context) +class ContractorPortfolioTrashView(View): + form_class = ContractorPortfolioTrashForm + + def post(self,request, *args, **kwargs): + form = self.form_class(_.merge({}, request.POST, kwargs), request=request) + if form.is_valid(): + portfolio = form.cleaned_data.get('pk') + portfolio.delete() + messages.info(request, 'Портфолио удален') + else: + messages.info(request, 'Произошла ошибка:
    {msg}
    '.format(msg=pformat(form.errors))) + + redirect_to = request.POST.get('next') + return redirect(redirect_to) + class CustomerProjectTrashView(View): form_class = CustomerProjectTrashForm @@ -485,4 +501,10 @@ class ContractorPortfolioUpdateView(UpdateView): return reverse('proje') +from django.views.generic import DeleteView +class PortfolioDelete(DeleteView): + model = Portfolio + success_url = reverse_lazy('users:contractor-profile') + + # import code; code.interact(local=dict(globals(), **locals())) diff --git a/ratings/__init__.py b/ratings/__init__.py index e69de29..f9d7f74 100644 --- a/ratings/__init__.py +++ b/ratings/__init__.py @@ -0,0 +1 @@ +default_app_config = 'ratings.apps.RatingsConfig' diff --git a/projects/templatetags/__init__.py b/ratings/management/__init__.py similarity index 100% rename from projects/templatetags/__init__.py rename to ratings/management/__init__.py diff --git a/specializations/templatetags/__init__.py b/ratings/management/commands/__init__.py similarity index 100% rename from specializations/templatetags/__init__.py rename to ratings/management/commands/__init__.py diff --git a/ratings/management/commands/recalculation_rating.py b/ratings/management/commands/recalculation_rating.py new file mode 100644 index 0000000..d9383eb --- /dev/null +++ b/ratings/management/commands/recalculation_rating.py @@ -0,0 +1,23 @@ +from django.core.management import BaseCommand +from django.db.models import Sum +from specializations.models import Specialization +from ratings.models import HistoryRating +from users.models import User,Team + + +class Command(BaseCommand): + + def handle(self, *args, **options): + users = User.objects.filter(is_superuser=False) + for user in users: + current_rating_info = HistoryRating.objects.filter(user_id=user.pk).aggregate(Sum('rating')) + current_rating = current_rating_info['rating__sum'] or 0 + user.rating = current_rating + user.save() + + teams = Team.objects.all() + for team in teams: + current_rating_info = HistoryRating.objects.filter(team_id=team.pk).aggregate(Sum('rating')) + current_rating = current_rating_info['rating__sum'] or 0 + team.rating = current_rating + team.save() diff --git a/ratings/management/commands/recalculation_spec.py b/ratings/management/commands/recalculation_spec.py new file mode 100644 index 0000000..acfb5d5 --- /dev/null +++ b/ratings/management/commands/recalculation_spec.py @@ -0,0 +1,43 @@ +from django.core.management import BaseCommand +from specializations.models import Specialization +from ratings.models import SpecializationRating +from users.models import User, Team + + +class Command(BaseCommand): + + def handle(self, *args, **options): + users = User.objects.values('pk', 'rating').filter(is_superuser=False).order_by('-rating') + teams = Team.objects.values('pk', 'rating').order_by('-rating') + result_list = [] + + for user in users: + result_list.append([user['rating'], 'user', user['pk']]) + + for team in teams: + result_list.append([team['rating'], 'team', team['pk'] ]) + + result_list = list(reversed(sorted(result_list))) + SpecializationRating.objects.all().delete() + specializations = Specialization.objects.all() + for spec in specializations: + i = 0 + for res in result_list: + if 'user' in res[1]: + user = User.objects.get(pk=res[2]) + team = None + specializations_current = user.contractor_specializations.all() + else: + team = Team.objects.get(pk=res[2]) + user = None + specializations_current = team.specializations.all() + + if spec in specializations_current: + i += 1 + spec_rating = SpecializationRating() + spec_rating.position = i + spec_rating.user = user + spec_rating.team = team + spec_rating.specialization = spec + spec_rating.save() + print('The end') diff --git a/ratings/models.py b/ratings/models.py index 4db1001..375907b 100644 --- a/ratings/models.py +++ b/ratings/models.py @@ -3,6 +3,7 @@ from django.utils import timezone from users.models import User, Team from specializations.models import Specialization + class HistoryRating(models.Model): user = models.ForeignKey(User, related_name='history_ratings', null=True, blank=True) team = models.ForeignKey(Team, related_name='history_ratings', null=True, blank=True) @@ -11,7 +12,7 @@ class HistoryRating(models.Model): description = models.TextField(blank=True) def __str__(self): - return self.rating + return '{0}'.format(self.rating) class Meta: verbose_name = 'История рейтинга' @@ -25,12 +26,10 @@ class SpecializationRating(models.Model): position = models.PositiveIntegerField(default=0) def __str__(self): - return self.position + return '{0}'.format(self.pk) class Meta: verbose_name = 'Рейтинг специализаций' verbose_name_plural = 'Рейтинги специализаций' - - diff --git a/ratings/templates/templatetags/ratings_widget.html b/ratings/templates/templatetags/ratings_widget.html new file mode 100644 index 0000000..35d53ae --- /dev/null +++ b/ratings/templates/templatetags/ratings_widget.html @@ -0,0 +1,12 @@ + diff --git a/ratings/templates/templatetags/specializations_widget.html b/ratings/templates/templatetags/specializations_widget.html new file mode 100644 index 0000000..c8a1175 --- /dev/null +++ b/ratings/templates/templatetags/specializations_widget.html @@ -0,0 +1,9 @@ +
    +

    Специализации:

    + {% for spec in specializations %} +
    + {{ spec.specialization.name }} + {{ spec.position }}-й +
    + {% endfor %} +
    diff --git a/ratings/templatetags/__init__.py b/ratings/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ratings/templatetags/specializtions_tags.py b/ratings/templatetags/specializtions_tags.py new file mode 100644 index 0000000..ba41ca1 --- /dev/null +++ b/ratings/templatetags/specializtions_tags.py @@ -0,0 +1,41 @@ +from django import template + +from archilance import util +from users.models import User, Team +from ratings.models import SpecializationRating + +register = template.Library() + +@register.inclusion_tag('templatetags/specializations_widget.html', takes_context=True) +def specialization_widget(context, user_id): + user_id = int(user_id) + specializations = SpecializationRating.objects.select_related('specialization').filter(user_id=user_id) + return { + 'specializations': specializations, + 'user_id': user_id, + } + +@register.inclusion_tag('templatetags/specializations_widget.html', takes_context=True) +def specialization_team_widget(context, team_id): + team_id = int(team_id) + specializations = SpecializationRating.objects.select_related('specialization').filter(team_id=team_id) + return { + 'specializations': specializations, + } + + + +@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) +def ratings_widget(context, user_id, class_name=None): + ratings = User.objects.get(pk=user_id).rating + return { + 'ratings': ratings, + 'class_name': class_name + } + +@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) +def ratings_team_widget(context, team_id): + ratings = Team.objects.get(pk=team_id).rating + return { + 'ratings': ratings, + } diff --git a/requirements/base.txt b/requirements/base.txt index cfc10d3..0e1edab 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -38,3 +38,4 @@ sqlparse==0.1.19 tornado==4.3 natsort django-mathfilters +gunicorn==19.6.0 diff --git a/specializations/templates/templatetags/specializations_widget.html b/specializations/templates/templatetags/specializations_widget.html deleted file mode 100644 index 97aa3e2..0000000 --- a/specializations/templates/templatetags/specializations_widget.html +++ /dev/null @@ -1,21 +0,0 @@ -
    -

    Специализации:

    - {% for spec in specializations %} -
    - {{ spec }} - 2-й -
    - {% endfor %} -
    -{#
    #} -{#

    #} -{# Специализации:#} -{#

    #} -{#
    #} -{# Интерьеры#} -{#
    #} -{# #} -{#
    #} -{# Визуализация/3D#} -{#
    #} -{#
    #} diff --git a/specializations/templatetags/specializtions_tags.py b/specializations/templatetags/specializtions_tags.py deleted file mode 100644 index 8f067c9..0000000 --- a/specializations/templatetags/specializtions_tags.py +++ /dev/null @@ -1,20 +0,0 @@ -from django import template - -from archilance import util -from users.models import User - - -register = template.Library() - -@register.inclusion_tag('templatetags/specializations_widget.html', takes_context=True) -def specialization_widget(context, user_id): - user_id = int(user_id) - user = util.get_or_none(User, pk=user_id) - if user: - specializations = user.contractor_specializations.all() - else: - specializations = None - return { - 'specializations': specializations, - 'user_id': user_id, - } diff --git a/templates/partials/header.html b/templates/partials/header.html index 63a2064..2e2c01f 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -7,7 +7,7 @@
    - + {% if request.user.is_authenticated %}
    {% endif %} - + {% if request.user.is_authenticated %}
    - + - + {% if request.user.is_contractor %}
    diff --git a/templates/registration/login.html b/templates/registration/login.html index b4d02ba..b155cc5 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -1,24 +1,32 @@ {% extends 'partials/base.html' %} {% block content %} -
    -

    Вход на сайт

    -
    -
    - {{ form.errors }} - {% csrf_token %} -
    - -
    -
    - -
    -
    - -
    + {% include 'partials/header.html' %} +
    +
    +
    +

    Вход на сайт

    +
    +
    + {{ form.errors }} + {% csrf_token %} +
    + +
    +
    + +
    +
    + +
    - + + +
    + {% include 'partials/footer.html' %} +
    +
    -
    {% endblock %} -a + diff --git a/users/admin.py b/users/admin.py index 1890f01..ca8f03e 100644 --- a/users/admin.py +++ b/users/admin.py @@ -5,13 +5,20 @@ from .models import User, Team, UserFinancialInfo, ContractorResume, ContractorR class UserAdmin(admin.ModelAdmin): readonly_fields = ('pk',) - list_display = ('username', 'email', 'get_groups', 'cro', 'is_active',) + list_display = ('username', 'email', 'get_groups', 'cro', 'is_active', 'rating',) + ordering = ('-rating',) def get_groups(self, obj): return ', '.join(g.name for g in obj.groups.all()) + +class TeamAdmin(admin.ModelAdmin): + list_display = ('name', 'rating', 'owner',) + ordering = ('-rating',) + + admin.site.register(User, UserAdmin) admin.site.register(UserFinancialInfo) -admin.site.register(Team) +admin.site.register(Team, TeamAdmin) admin.site.register(ContractorResume) admin.site.register(ContractorResumeFiles) diff --git a/users/migrations/0007_auto_20160808_1557.py b/users/migrations/0007_auto_20160808_1557.py new file mode 100644 index 0000000..95cf4cc --- /dev/null +++ b/users/migrations/0007_auto_20160808_1557.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-08 12:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0006_auto_20160805_1442'), + ] + + operations = [ + migrations.RenameField( + model_name='user', + old_name='contractor_rating', + new_name='rating', + ), + migrations.AddField( + model_name='team', + name='rating', + field=models.FloatField(default=0.0), + ), + ] diff --git a/users/mixins.py b/users/mixins.py index 6bf0e1b..a1bb811 100644 --- a/users/mixins.py +++ b/users/mixins.py @@ -12,3 +12,9 @@ class CheckForUserMixin(object): else: return HttpResponseForbidden('403 Forbidden') return super().dispatch(request, *args, **kwargs) + + +class OwnershipMixin(object): + + def dispatch(self, request, *args, **kwargs): + pass diff --git a/users/models.py b/users/models.py index 9dd7cd0..a3d995c 100644 --- a/users/models.py +++ b/users/models.py @@ -120,7 +120,7 @@ class User(AbstractBaseUser, PermissionsMixin): avatar = models.ImageField(upload_to='users/avatars/', blank=True) contractor_answers = GenericRelation('projects.Answer') - contractor_rating = models.FloatField(default=0.0) + rating = models.FloatField(default=0.0) contractor_resume = models.OneToOneField(ContractorResume, related_name='contractor', blank=True, null=True) contractor_specializations = TreeManyToManyField(Specialization, related_name='contractors', blank=True) contractor_status = models.CharField(default='free', max_length=20, choices=STATUSES) @@ -189,6 +189,7 @@ class Team(models.Model): owner = models.OneToOneField(User, related_name='team', blank=True, null=True) specializations = TreeManyToManyField(Specialization, related_name='teams', blank=True) contractors = models.ManyToManyField(User, limit_choices_to={'groups__name': 'Исполнители'}, related_name ='teams', blank=True) + rating = models.FloatField(default=0.0) def __str__(self): return self.name diff --git a/users/templates/contractor_office.html b/users/templates/contractor_office.html index debb866..4b495d7 100644 --- a/users/templates/contractor_office.html +++ b/users/templates/contractor_office.html @@ -1,87 +1,98 @@ {% extends 'partials/base.html' %} {% load staticfiles %} +{% load specializtions_tags %} {% load thumbnail %} {% block content %} {% include 'partials/header.html' %} - -
    -
    -
    -

    Личный кабинет

    -
    - -
    - +
    + +
    +
    + + + {% if not contractor.is_owner_team %} + {% endif %} -
    - - - -
    - -
    -
    -
    +
    + + + +
    + +
    +
    +
    {% thumbnail contractor.avatar "265x264" crop="center" as im %} @@ -89,219 +100,183 @@ {% endthumbnail %}
    - +
    - -
    -
    -

    - {{ contractor.team }} -

    -

    Россия, Москва

    -{# #} - - - -
    Свободен
    - написать сообщение -
    - -
    -
    -

    - Специализации: -

    -
    - Интерьеры - 2-й -
    -
    - Визуализация/3D - 45-й -
    -
    - Экстерьеры - 10-й -
    -
    - Архитектура - 3-й -
    -
    - 3D Моделирование - 100-й -
    -
    -
    - - -
    - - - - - - -
    -
    - -
    - {% for p in portfolios %} + +
    -
    -
    -
    -
    -
    -
    -

    {{ p.name }}

    -
    - -
    - -
    -
    -
    - -
    -
    -
    +

    + {{ contractor.team }} +

    +

    Россия, Москва

    + {# #} + + + +
    Свободен
    + написать сообщение
    - {% endfor %} +
    + {% specialization_team_widget contractor.team.pk %}
    -
    -
    - показать еще +
    + {% if contractor.team %} + {% ratings_team_widget contractor.team.pk %} + {% endif %} +
    +
    +

    Есть допуск СРО

    -
    -
    - {% for ws in work_sells %} -
    -
    -
    -
    + + +
    +
    + +
    + {% for p in portfolios %} +
    +
    +
    +
    +
    -
    -
    - {{ ws.budget }} +
    +

    {{ p.name }}

    +
    + +
    + +
    +
    +
    + +
    -
    -

    {{ ws }}

    + {% endfor %} -
    +
    + +
    + - {% endfor %} +
    -
    -
    - показать еще + +
    + +
    + {% for ws in work_sells %} +
    +
    +
    +
    +
    +
    +
    + {{ ws.budget }} +
    +
    +
    +
    +

    {{ ws }}

    + +
    +
    + {% endfor %} +
    +
    -
    -
    -
    -
    -

    - Иванов Петр Иванович -

    +
    +
    +
    +

    + Иванов Петр Иванович +

    Безопасная сделка - -

    - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum +

    +

    + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum -

    +

    +
    -
    -
    - - {% include 'partials/footer.html' %} -
    -
    +
    + + {% include 'partials/footer.html' %} +
    +
    {% endblock %} diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 3c0f013..38d52e8 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -1,6 +1,5 @@ {% extends 'partials/base.html' %} -{% load projects_tags %} {% load specializtions_tags %} {% load thumbnail %} @@ -28,20 +27,8 @@ -
  • - - редактировать профиль - - -
  • -
  • - - редактировать профиль - - -
  • {% endif %} - {% if contractor.pk != user.id %} + {% if contractor.pk != request.user.pk and request.user.is_contractor %}
  • @@ -49,22 +36,26 @@
  • + {% endif %} + {% if contractor.pk != request.user.pk %}
  • - + написать сообщение
  • + {% endif %} + {% if request.user.is_customer %}
  • предложить заказ
  • - {% endif %} +
    @@ -159,7 +150,12 @@
    - +
    + {% csrf_token %} + + +
    +
    @@ -200,13 +196,17 @@ {% for ws in user.work_sell.all %}
    -
    + + {% thumbnail ws.get_cover "224x224" crop="center" as im %} +
    + {% endthumbnail %} +
    {{ ws.budget }} +
    @@ -219,7 +219,12 @@
    - +
    + {% csrf_token %} + + +
    +
    diff --git a/users/templates/partials/customer_profile_info_block.html b/users/templates/partials/customer_profile_info_block.html index bbb1c08..1c74fc5 100644 --- a/users/templates/partials/customer_profile_info_block.html +++ b/users/templates/partials/customer_profile_info_block.html @@ -1,6 +1,4 @@ -{% load projects_tags %} - - +{% load specializtions_tags %}
    diff --git a/users/templates/user_profile_edit.html b/users/templates/user_profile_edit.html index c3ec3e0..7086ada 100644 --- a/users/templates/user_profile_edit.html +++ b/users/templates/user_profile_edit.html @@ -22,7 +22,9 @@
    - profile-image + {% if form.avatar.value %} + profile-image + {% endif %}