commit
d98be575c1
34 changed files with 1022 additions and 215 deletions
@ -0,0 +1,6 @@ |
||||
from rest_framework.test import APITestCase |
||||
|
||||
|
||||
class FileUploadTests(APITestCase): |
||||
pass |
||||
|
||||
@ -0,0 +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 += '<div class="col-lg-12 insetCommChat"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">ВЫ</p> <span>13.0.2016</span></div>' +
|
||||
// '<p class="textCommChat">' + message.msg + '</p></div>';
|
||||
// };
|
||||
//
|
||||
// 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 = '<p>'+ file.name+'</p>';
|
||||
// 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 += '<div class="col-lg-12 insetCommChat"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">' + senderName + '</p> <span>' + v.created + '</span></div>' +
|
||||
// '<p class="textCommChat">' + v.text + '</p></div>';
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// });
|
||||
//
|
||||
// // Вытащить сообщения для чата заказа
|
||||
// $('.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 += '<div class="col-lg-12 insetCommChat"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">' + senderName + '</p> <span>' + v.created + '</span></div>' +
|
||||
// '<p class="textCommChat">' + v.text + '</p></div>';
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// $.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 += '<li>'+ v.text +'<li>';
|
||||
//
|
||||
// });
|
||||
// $(".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 += '<li class="reserved">Сумма за этап '+ i +'.Зарезервирована.</li>';
|
||||
// }else{
|
||||
// stagesReservedHtml += '<li class="unreserved">Сумма за этап '+ i +'.Не зарезервирована.</li>';
|
||||
// }
|
||||
// htmlInbox += '<div data-id="' + v.id + '" class="numberStepp box-sizing stage-block-approve"><div class="insetNumStepp">' +
|
||||
// '<p class="titleNumStepp"><span>Этап ' + v.pos + '</span>' + v.name + '</p>' +
|
||||
// '<p class="textNumStepp">Результаты этапа:' + v.result + '</p><div>' +
|
||||
// '<p>'+ v.status+'</p><span>' + v.cost + '<i class="fa fa-rub"></i></span></div></div></div>';
|
||||
// });
|
||||
// htmlInbox += '<div class="textAreaBlock2 FFD box-sizing disTab"><a id="approve-stages" href="javascript:void()">согласовать</a></div>';
|
||||
//
|
||||
// }
|
||||
// $("#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 += '<div class="col-lg-12 insetCommChat ' + className + '"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">' + senderName + '</p> <span>' + v.created + '</span></div>' +
|
||||
// '<p class="textCommChat">' + v.text + '</p></div>';
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// });
|
||||
//
|
||||
// //Добавить сообщение для исполнителей в группе
|
||||
// $("#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 + '<div class="col-lg-12 insetCommChat"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">Вы</p> <span>Сейчас</span></div>' +
|
||||
// '<p class="textCommChat">' + chatMessage + '</p></div>');
|
||||
//
|
||||
// $("#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 += '<div class="col-lg-12 insetCommChat ' + className + '"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">' + senderName + '</p><span>' + v.created + '</span></div>' +
|
||||
// '<p class="textCommChat">' + v.text + '</p></div>';
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// $.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 = '<p class="textStepss">Какое кол-во этапов подразумевает работа? ' +
|
||||
// '<input type="text" id="countStage" value="'+ stageCountVal +'"size="3"/></p>';
|
||||
//
|
||||
// if (stageCount == 0){
|
||||
// htmlInboxStage += '<div class="numberStepp box-sizing" id="stage1">' +
|
||||
// '<p>Этап <span class="stage-span-id">1</span></p><form class="new-stages-form" id="stage-form">' +
|
||||
// '<label for="">Название</label><input class="form-control" name="name" type="text" />' +
|
||||
// '<label for="">Цена</label><input class="form-control" name="cost" type="text" />' +
|
||||
// '<input class="form-control" name="order" type="text" value="'+ orderId +'" class="orderStagesInput"/> />' +
|
||||
// '<label for="">Срок</label><input class="form-control" name="term" type="text" />' +
|
||||
// '<label for="">Результат</label><input class="form-control" name="result" type="text" />' +
|
||||
// '</form></div>';
|
||||
// }
|
||||
// var statusNotAgreed = true;
|
||||
// $.each(json.results, function (i, v) {
|
||||
// if (v.status == "not_agreed") {
|
||||
// htmlInbox += '<div class="numberStepp box-sizing">' +
|
||||
// '<p>Этап</p><form class="update-stages-form" id="stage-form-'+ v.pos +'">' +
|
||||
// '<label for="">Название</label><input class="form-control" type="text" value="'+ v.name +'" />' +
|
||||
// '<label for="">Цена</label><input class="form-control" type="text" value="'+ v.cost +'" />' +
|
||||
// '<input class="form-control" type="hidden" value="'+ v.order +'" />' +
|
||||
// '<label for="">Срок</label><input class="form-control" type="text" value="'+ v.term +'" />' +
|
||||
// '<label for="">Результат</label><input class="form-control" type="text" value="'+ v.result +'" />' +
|
||||
// '</form></div>';
|
||||
// } else {
|
||||
// statusNotAgreed = false;
|
||||
// htmlInboxStage = "";
|
||||
// htmlInbox += '<div class="numberStepp box-sizing"><div class="insetNumStepp">' +
|
||||
// '<p class="titleNumStepp"><span>Этап ' + v.pos + '</span>' + v.name + '</p>' +
|
||||
// '<p class="textNumStepp">Результаты этапа:' + v.result + '</p><div>' +
|
||||
// '<p>до 16.03.2015</p><span>' + v.cost + '<i class="fa fa-rub"></i></span></div></div></div>';
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// if (statusNotAgreed) {
|
||||
// htmlInbox += '<div class="box-sizing disTab" style="text-align:center;"><div class="checkbox"><input type="checkbox" style="opacity:1">Перейти в режим безопасной сделки' +
|
||||
// '</div></div><div class="textAreaBlock2 box-sizing disTab">' +
|
||||
// '<a href="javascript:void()" id="addStagesForm">отправить на согласование</a> </div>';
|
||||
// }
|
||||
// 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 += '<div class="col-lg-12 insetCommChat ' + className + '"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">' + senderName + '</p> <span>' + v.created + '</span></div>' +
|
||||
// '<p class="textCommChat">' + v.text + '</p></div>';
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// });
|
||||
//
|
||||
// $('#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 += '<div class="col-lg-12 insetCommChat"><div class="topCommChat">' +
|
||||
// '<p class="nameCommChat">Иванов</p> <span>13.0.2016</span></div>' +
|
||||
// '<p class="textCommChat">' + message.msg + '</p></div>';
|
||||
//
|
||||
// };
|
||||
//
|
||||
// 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 = "";
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@ -1,42 +0,0 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>Title</title> |
||||
</head> |
||||
<body> |
||||
<h1>Всем привет , дети мои!!</h1> |
||||
<div id="output"> |
||||
</div> |
||||
|
||||
<form id="chatform"> |
||||
<input id="text" type="text" /> |
||||
<input type="submit" /> |
||||
</form> |
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> |
||||
<script type="text/javascript"> |
||||
$(document).ready(function(){ |
||||
var url = 'ws://127.0.0.1:8888/chat'; |
||||
var socket = new WebSocket(url); |
||||
|
||||
socket.onopen = function(){ |
||||
console.log("Соединение установлено"); |
||||
socket.send("start"); |
||||
} |
||||
|
||||
socket.onmessage = function (event) { |
||||
console.log(event.data); |
||||
var data = JSON.parse(event.data); |
||||
output = output + '<h3>'+ data.msg +'</h3>'; |
||||
$("#output").html(output); |
||||
} |
||||
$('form').submit(function(e){ |
||||
e.preventDefault(); |
||||
var currentText = $("#text").val(); |
||||
socket.send(currentText); |
||||
}); |
||||
}); |
||||
|
||||
</script> |
||||
</body> |
||||
</html> |
||||
@ -1,61 +0,0 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>Title</title> |
||||
</head> |
||||
<body> |
||||
<h1>Chat</h1> |
||||
<div id="inbox"> |
||||
{% for message in messages %} |
||||
<h1>{{ message["body"] }}</h1> |
||||
<h3>{{ message["time"] }} </h3> |
||||
{% end%} |
||||
</div> |
||||
<form method="post" id="messageform"> |
||||
<textarea id="message" name="message"></textarea> |
||||
<input type="submit" /> |
||||
</form> |
||||
<script type="text/javascript"> |
||||
window.onload = function(){ |
||||
var socket = new SocketHandler(); |
||||
var form = document.getElementById('messageform'); |
||||
|
||||
form.onsubmit = function(e){ |
||||
e.preventDefault(); |
||||
console.log('submit click'); |
||||
socket.send_message(form); |
||||
} |
||||
}; |
||||
|
||||
var SocketHandler = function(){ |
||||
var url = 'ws://' + location.host + '/chatsocket/main/'; |
||||
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); |
||||
message = JSON.parse(event.data); |
||||
var inbox = document.getElementById('inbox'); |
||||
inbox.innerHTML += '<h2>' + message.message + '</h2>'; |
||||
}; |
||||
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)); |
||||
|
||||
} |
||||
|
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
||||
@ -1,33 +0,0 @@ |
||||
{% extends 'partials/base.html' %} |
||||
{% block content %} |
||||
<h1>Test page </h1> |
||||
{% endblock %} |
||||
{% block js_block %} |
||||
<script type="text/javascript"> |
||||
$(function () { |
||||
|
||||
$.ajax({ |
||||
url: '/api/stages/4/', |
||||
type: 'PUT', |
||||
beforeSend: function (xhr) { |
||||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
||||
}, |
||||
|
||||
data: { |
||||
name: 'Test name.HA HA HA nnnnnn ', |
||||
cost: 100, |
||||
result: 'Результат', |
||||
order: 1, |
||||
}, |
||||
dataType: 'json', |
||||
success: function (json) { |
||||
console.log(json); |
||||
}, |
||||
error: function(e){ |
||||
console.log(e); |
||||
} |
||||
}); |
||||
}); |
||||
</script> |
||||
|
||||
{% endblock %} |
||||
@ -0,0 +1,20 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.7 on 2016-08-03 17:03 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('projects', '0012_merge'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='answer', |
||||
name='portfolios', |
||||
field=models.ManyToManyField(blank=True, related_name='portfolios_answers', to='projects.Portfolio'), |
||||
), |
||||
] |
||||
@ -0,0 +1,5 @@ |
||||
from django.contrib import admin |
||||
from .models import SpecializationRating, HistoryRating |
||||
|
||||
admin.site.register(SpecializationRating) |
||||
admin.site.register(HistoryRating) |
||||
@ -0,0 +1,5 @@ |
||||
from django.apps import AppConfig |
||||
|
||||
|
||||
class RatingsConfig(AppConfig): |
||||
name = 'ratings' |
||||
@ -0,0 +1,51 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.7 on 2016-08-04 15:52 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
import django.utils.timezone |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
initial = True |
||||
|
||||
dependencies = [ |
||||
('specializations', '0001_initial'), |
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||
('users', '0004_user_contractor_rating'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='HistoryRating', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('rating', models.IntegerField(default=0)), |
||||
('created', models.DateTimeField(default=django.utils.timezone.now)), |
||||
('description', models.TextField(blank=True)), |
||||
('team', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='history_ratings', to='users.Team')), |
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='history_ratings', to=settings.AUTH_USER_MODEL)), |
||||
], |
||||
options={ |
||||
'verbose_name': 'История рейтинга', |
||||
'verbose_name_plural': 'Истории рейтинга', |
||||
}, |
||||
), |
||||
migrations.CreateModel( |
||||
name='SpecializationRating', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('position', models.PositiveIntegerField(default=0)), |
||||
('specialization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='specialization_rating', to='specializations.Specialization')), |
||||
('team', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='specialization_rating', to='users.Team')), |
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='specialization_rating', to=settings.AUTH_USER_MODEL)), |
||||
], |
||||
options={ |
||||
'verbose_name': 'Рейтинг специализаций', |
||||
'verbose_name_plural': 'Рейтинги специализаций', |
||||
}, |
||||
), |
||||
] |
||||
@ -0,0 +1,36 @@ |
||||
from django.db import models |
||||
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) |
||||
rating = models.IntegerField(default=0) |
||||
created = models.DateTimeField(default=timezone.now) |
||||
description = models.TextField(blank=True) |
||||
|
||||
def __str__(self): |
||||
return self.rating |
||||
|
||||
class Meta: |
||||
verbose_name = 'История рейтинга' |
||||
verbose_name_plural = 'Истории рейтинга' |
||||
|
||||
|
||||
class SpecializationRating(models.Model): |
||||
user = models.ForeignKey(User, related_name='specialization_rating', null=True, blank=True) |
||||
team = models.ForeignKey(Team, related_name='specialization_rating', null=True, blank=True) |
||||
specialization = models.ForeignKey(Specialization, related_name='specialization_rating') |
||||
position = models.PositiveIntegerField(default=0) |
||||
|
||||
def __str__(self): |
||||
return self.position |
||||
|
||||
class Meta: |
||||
verbose_name = 'Рейтинг специализаций' |
||||
verbose_name_plural = 'Рейтинги специализаций' |
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@ |
||||
from django.test import TestCase |
||||
|
||||
# Create your tests here. |
||||
@ -0,0 +1,3 @@ |
||||
from django.shortcuts import render |
||||
|
||||
# Create your views here. |
||||
@ -0,0 +1,20 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.7 on 2016-08-04 15:52 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('users', '0003_auto_20160726_1931'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='user', |
||||
name='contractor_rating', |
||||
field=models.FloatField(default=0.0), |
||||
), |
||||
] |
||||
Loading…
Reference in new issue