remotes/origin/PR-39
ArturBaybulatov 10 years ago
commit ea9d8920c0
  1. 1
      archilance/settings/base.py
  2. 23
      assets/css/extra.css
  3. 13
      assets/js/chat.js
  4. 2
      assets/lib/jquery-jgrowl/jquery.jgrowl.min.js
  5. 0
      assets/lib/jquery.cookie/jquery.cookie.min.js
  6. 2
      chat/chat.py
  7. 14
      chat/serializers.py
  8. 17
      chat/templates/chat_customer.html
  9. 2
      projects/models.py
  10. 1
      requirements/base.txt
  11. 6
      templates/partials/base.html
  12. 16
      wallets/admin.py
  13. 20
      wallets/migrations/0010_auto_20160830_1640.py
  14. 20
      wallets/migrations/0011_withdraw_complete.py
  15. 25
      wallets/models.py
  16. 34
      wallets/signals.py
  17. 21
      wallets/templates/score-detail.html
  18. 12
      wallets/views.py

@ -43,6 +43,7 @@ THIRD_PARTY_APPS = [
'generic_relations', # https://github.com/Ian-Foote/rest-framework-generic-relations
'hitcount',
'django_activeurl',
'import_export',
]
LOCAL_APPS = [

@ -111,3 +111,26 @@
#jGrowl .jGrowl-notification a, #jGrowl .jGrowl-notification a:visited {
color: #777620;
}
#document-send-contact a {
float: left;
font-family: 'pfdintextcomppro-regular', sans-serif;
color: #373737;
font-size: 15px;
border:0;
padding: 0px;
text-transform:lowercase;
}
.documentsChat a.file-link, .documentsChat a.file-link:link, .documentsChat a.file-link:visited {
color: #5a5a5a;
border-radius: 0;
border: 0;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 12px;
font-style: italic;
padding:0;
background:none;
float: none;
margin: 19px 0 -10px 0;
}

@ -165,7 +165,7 @@ $(function () {
console.log(json);
$.each(json.results, function (i, v) {
docList.innerHTML += '<li style="word-break: break-all;">' + v.file + '</li>';
docList.innerHTML += '<li style="word-break: break-all;"><a class="file-link" href="'+ v.file_url +'">' + v.file + '</a><div style="right:-10px;"></divsty></li>';
});
},
error: function (e) {
@ -283,6 +283,7 @@ $(function () {
if (chatMessage) {
$("#chat-order-add .errorEmptyMessage").hide();
chatMessage += '<br />' + $("#document-send-order").html();
socket.add_contact_message({
"format_type": "add_message_order",
"data": {
@ -302,7 +303,7 @@ $(function () {
});
// Добавление сообщения для контакта
$('#contact-chat-add-message').on('click', function (e) {
e.preventDefault();
var chatMessage = $("#chat").val();
@ -310,6 +311,7 @@ $(function () {
var senderId = $("#senderContactId").val();
if (chatMessage) {
$("#contact-chat-form .errorEmptyMessage").hide();
chatMessage += '<br />' + $("#document-send-contact").html();
socket.add_contact_message({
"format_type": "add_message_contact",
"data": {
@ -386,6 +388,7 @@ $(function () {
recipent: $("#chat-order-add #recipentId").val(),
order: $("#chat-order-add #orderId").val(),
}
console.log(data.formData);
});
//Загрузка документов
@ -404,8 +407,8 @@ $(function () {
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
var currentValue = '';
currentValue += file.id + ';';
// var currentValue = '';
// currentValue += file.id + ';';
//$("#documentSendIds").val(currentValue);
var htmlImg = '<p>' + file.name + '</p>';
var document_send = $(htmlImg).appendTo("#document-send-order");
@ -450,7 +453,7 @@ $(function () {
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
var htmlImg = '<p>' + file.name + '</p>';
var htmlImg = '<a href="#">' + file.name + '</a>';
var document_send = $(htmlImg).appendTo("#document-send-contact");
});
},

File diff suppressed because one or more lines are too long

@ -59,7 +59,7 @@ class ChatHandler(websocket.WebSocketHandler):
order_id = message_data['data'].get('order_id', None)
team_id = message_data['data'].get('team_id', None)
message = message_data['data'].get('chat_message', None)
message = html.escape(message)
# message = html.escape(message)
message = message.replace('\n', '<br />')
answer_type = message_data['format_type']

@ -6,18 +6,32 @@ from users.serializers import UserSerializer
class DocumentsSerializer(ModelSerializer):
file = serializers.SerializerMethodField()
file_size = serializers.SerializerMethodField()
file_url = serializers.SerializerMethodField()
class Meta:
model = Documents
fields = (
'file',
'file_size',
'file_url',
'sender',
'recipent',
'team',
'order',
)
def get_file(self, obj):
return obj.file.name
def get_file_size(self, obj):
return obj.file.size
def get_file_url(self, obj):
return obj.file.url
class MessageSerializer(ModelSerializer):

@ -117,8 +117,8 @@
{% if order.order.contractor %}
data-recipent-id="{{ order.order.contractor.pk }}"
{% else %}
data-recipent-id="{{ order.order.team.pk }}"
{% endif %}data-id="{{ order.order.id }}">
data-recipent-id="{{ order.order.team.owner.pk }}"
{% endif %} data-id="{{ order.order.id }}">
<span class="dimovChat"></span>
<p class="titleOB">{{ order }}</p>
<div class="hideOBB">
@ -350,6 +350,7 @@
var stagesInWork = [];
var stagesPaidProcess = [];
var stagesCompleted = [];
var stagePaidCount = 0;
var stagesReservedHtml = "";
$.each(stagesResults, function (i, v) {
@ -365,6 +366,10 @@
stagesPaidProcess.push(v);
}
if(v.is_paid){
stagePaidCount +=1;
}
if (v.status == "not_agreed") {
htmlInbox += '<div class="numberStepp box-sizing">' +
'<p>Этап</p><form class="update-stages-form" data-stage-id="' + v.id + '" id="stage-form-' + v.pos + '">' +
@ -397,7 +402,11 @@
}
});
if (stagesResults.length == stagePaidCount && data.secure){
$("#reserve-button").parent().hide();
}else {
$("#reserve-button").parent().show();
}
if (statusNotAgreed) {
if(!data.secure) {
@ -656,7 +665,7 @@
console.log(json);
$.each(json.results, function (i, v) {
docList.innerHTML += '<li style="word-break: break-all;">'+ v.file+'</li>';
docList.innerHTML += '<li style="word-break: break-all;"><a class="file-link" href="'+ v.file_url +'">'+ v.file+'</a></li>';
});
},
error: function(e){

@ -146,7 +146,7 @@ class Answer(models.Model):
term_type_labels = {
'hour': 'час,часа,часов',
'day': 'день,дня,дней',
'month': 'месяц,мксяца,месяцев',
'month': 'месяц,месяца,месяцев',
'project': 'проект,проект,проект'
}
return term_type_labels.get(self.term_type)

@ -43,3 +43,4 @@ rest-framework-generic-relations
django-hitcount
django-activeurl==0.1.9
wagtail==1.6
django-import-export==0.4.5

@ -24,7 +24,7 @@
<link rel='stylesheet' href='{% static "css/swiper.min.css" %}'>
<link rel='stylesheet' href='{% static "lib/jquery.fileupload/css/jquery.fileupload.css" %}'>
<link rel='stylesheet' href='{% static "js/magnific-popup.css" %}'>
{# <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.1/jquery.jgrowl.min.css"> <!-- TODO: Download locally -->#}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.1/jquery.jgrowl.min.css"> <!-- TODO: Download locally -->
<link rel='stylesheet' href='{% static "css/main.css" %}'>
<link rel='stylesheet' href='{% static "css/extra.css" %}'> <!-- Our additional CSS -->
@ -67,9 +67,9 @@
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload.js" %}'></script>
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload-process.js" %}'></script>
<script src='{% static "js/jquery.magnific-popup.min.js" %}'></script>
<script src='{% static "lib/jquery.cookie/jquery.cookie.min.js" %}'></script>
{#<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.1/jquery.jgrowl.min.js"></script> <!-- TODO: Download locally -->#}
<script src='{% static "lib/jquery.cookie/jquery.cookie.min.js" %}'></script>
<script src='{% static "lib/jquery-jgrowl/jquery.jgrowl.min.js" %}'></script>
<script src='{% static "my-libs.js" %}'></script>

@ -1,4 +1,6 @@
from django.contrib import admin
from import_export import resources
from import_export.admin import ImportExportModelAdmin
from .models import InvoiceHistory, WithDraw, Transaction, Wallet
@ -7,10 +9,20 @@ class InvoiceHistoryAdmin(admin.ModelAdmin):
list_display = ('comment', 'sum', 'user','balance',)
class WithDrawAdmin(admin.ModelAdmin):
list_display = ('sum','created','user',)
# class WithDrawAdmin(admin.ModelAdmin):
# list_display = ('sum','created','user',)
class WithDrawResource(resources.ModelResource):
class Meta:
model = WithDraw
export_order = ('id', 'sum', 'yandex_card', 'user')
class WithDrawAdmin(ImportExportModelAdmin):
list_display = ('sum','created', 'yandex_card', 'user', 'complete',)
class TransactionAdmin(admin.ModelAdmin):
list_display = ('customer','complete',)

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-30 13:40
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wallets', '0009_transaction_stages_id'),
]
operations = [
migrations.AlterField(
model_name='invoicehistory',
name='type',
field=models.CharField(choices=[('score', 'Счет'), ('history', 'История')], default='score', max_length=20),
),
]

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-31 10:23
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wallets', '0010_auto_20160830_1640'),
]
operations = [
migrations.AddField(
model_name='withdraw',
name='complete',
field=models.BooleanField(default=False),
),
]

@ -1,9 +1,12 @@
from django.db import models
from django.db.models import Sum
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator
from django.utils import timezone
from users.models import User
TYPES = (
('minus', 'Снятие'),
('plus', 'Приход'),
@ -20,11 +23,15 @@ class Wallet(models.Model):
class InvoiceHistory(models.Model):
TYPES = (
('score', 'Счет'),
('history', 'История'),
)
comment = models.TextField(blank=True)
created = models.DateTimeField(default=timezone.now)
sum = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True)
balance = models.DecimalField(max_digits=10, decimal_places=0, default=0)
type = models.CharField(max_length=20, blank=True, null=True)
type = models.CharField(max_length=20, choices=TYPES,default='score')
user = models.ForeignKey(User, related_name='invoice_history')
def __str__(self):
@ -32,9 +39,12 @@ class InvoiceHistory(models.Model):
def save(self, *args, **kwargs):
if self.pk is None:
current_sum_info = InvoiceHistory.objects.filter(user=self.user).aggregate(Sum('sum'))
current_sum_info = InvoiceHistory.objects.filter(user=self.user,type="score").aggregate(Sum('sum'))
current_sum = current_sum_info['sum__sum'] or 0
self.balance = current_sum + self.sum
if self.type == "score":
self.balance = current_sum + self.sum
else:
self.balance = current_sum
super().save(*args, **kwargs)
class Meta:
@ -48,10 +58,19 @@ class WithDraw(models.Model):
created = models.DateTimeField(default=timezone.now)
yandex_card = models.CharField(max_length=30)
user = models.ForeignKey(User, related_name='with_draw')
complete = models.BooleanField(default=False)
def __str__(self):
return self.yandex_card
def clean(self):
if not self.pk:
current_score_info = InvoiceHistory.objects.filter(user=self.user, type="score").aggregate(Sum('sum'))
# withdraw_sum_not_complete = WithDraw.objects.filter(user=self.user,complete=False).aggregate(Sum('sum'))
current_score = current_score_info['sum__sum'] or 0
if not self.sum is None and self.sum > current_score:
raise ValidationError("Сумма должна быть меньше " + str(current_score))
class Meta:
verbose_name = 'Заявка на вывод средств'
verbose_name_plural = 'Заявки на вывод средств'

@ -28,26 +28,48 @@ def add_invoice_history(sender, instance, created, **kwargs):
inv_history.comment = 'Пополнение счета'
inv_history.sum = instance.sum
inv_history.user = instance.customer
inv_history.type = "score"
inv_history.save()
@receiver(post_save, sender=Stage)
def add_contractor_inv_from_stage(sender, instance, created, **kwargs):
if instance.close_contractor and instance.close_customer and instance.is_paid:
inv = InvoiceHistory()
inv.comment = 'Сумма за завершение этапа ' + instance.name + ' заказа ' + str(instance.order)
inv.sum = instance.cost
inv.type = "score"
if instance.order.contractor:
inv.user = instance.order.contractor
else:
inv.user = instance.order.team.owner
inv.save()
@receiver(post_save, sender=Transaction)
def reserve_stages(sender, instance, created, **kwargs):
if 'reservation' in instance.type and instance.complete:
inv_history = InvoiceHistory()
inv_history.comment = 'Резервирование средств за этапы'
inv_history.sum = instance.sum
inv_history.user = instance.customer
inv_history.save()
order = None
stages_names = []
stages_ids_raw = instance.stages_id
if stages_ids_raw:
stages_ids = [s for s in stages_ids_raw.split(';') if s]
for pk in stages_ids:
stage = Stage.objects.get(pk=pk)
stages_names.append(stage.name)
stage.is_paid = True
order = stage.order
stage.save()
inv_history = InvoiceHistory()
inv_history.comment = 'Резервирование средств за этапы ' + ' , '.join(stages_names) + ' заказа' + str(order)
inv_history.sum = instance.sum
inv_history.user = instance.customer
inv_history.type = "history"
inv_history.save()

@ -16,13 +16,14 @@
<div class="triangle1"></div>
<p>{{ user_score_balance }} <i class="fa fa-rub"></i></p>
{% if user_score.is_customer and user_score_balance > 0 %}
{% if user_score.is_customer %}
<div class="col-lg-12">
<a href="#" data-toggle="modal" data-target="#fullfill-balance" class="linkS linkS1">пополнить</a>
</div>
{% endif %}
{% if user_score.is_contractor %}
{% if user_score.is_contractor %}
<div class="col-lg-12">
<a href="#" data-toggle="modal" data-target="#withdraw-money" class="linkS linkS2">вывести средства</a>
</div>
@ -41,12 +42,14 @@
<div class="modal-body">
<div style="height: 150px;">
<div class="textAreaBlock2 text-nn box-sizing disTab">
<p>Кол-во денег</p>
<p>Кол-во денег<span style="color: red; margin-left:8px; font-size: 12px;"
class="error-{{ form.sum.html_name }}"></span> </p>
<input type="text" name="{{ form.sum.html_name }}">
</div>
<div class="textAreaBlock2 text-nn box-sizing disTab">
<p>Номер Яндекс кошелька</p>
<p>Номер Яндекс кошелька <span style="color: red; margin-left:8px; font-size: 12px;"
class="error-{{ form.yandex_card.html_name }}"></span> </p>
<input type="text" name="{{ form.yandex_card.html_name }}">
<input type="hidden" name="{{ form.user.html_name }}" value="{{ user_score.pk }}">
</div>
@ -104,6 +107,7 @@
<tr>
<th>Дата</th>
<th>Описание</th>
<th>Поступление/Списание</th>
<th>Баланс</th>
</tr>
@ -113,6 +117,7 @@
<td>
{{ history.comment }}
</td>
<td>
{{ history.sum }}
<i class="fa fa-rub"></i>
@ -151,8 +156,16 @@
dataType: 'json',
success: function (data) {
console.log(data);
if (data.status == 'ok') {
location.reload();
}else if (data.status == 'error'){
$.each(data.errors, function (k, v) {
if (k == '__all__'){
$('.error-sum').html(v).show();
}
$('.error-' + k).html(v).show();
});
}
},
error: function (jqXHR, exception) {

@ -26,7 +26,7 @@ class ScoreDetailView(DetailView):
context = super().get_context_data(**kwargs)
user_score_balance = InvoiceHistory.objects.filter(user=self.get_object()).aggregate(Sum('sum'))
context['user_score_balance'] = user_score_balance['sum__sum'] or 0
context['form'] = WithDrawForm
context['form'] = WithDrawForm()
return context
@ -37,14 +37,16 @@ class ScoreView(LoginRequiredMixin, View):
# transaction = Transaction.objects.get_or_create(customer=request.user, complete=False)
transaction = Transaction.objects.get_or_create(customer=request.user, type='add', complete=False)
user_score = get_object_or_404(User.objects, pk=kwargs.get('pk'))
current_sum_info = InvoiceHistory.objects.filter(user=user_score).aggregate(Sum('sum'))
current_sum_info = InvoiceHistory.objects.filter(user=user_score,type="score").aggregate(Sum('sum'))
user_score_balance = current_sum_info['sum__sum'] or 0
form = WithDrawForm
return render(request, self.template_name, {
'transaction': transaction[0],
'YANDEX_MONEY': settings.YANDEX_MONEY,
'user_score': user_score,
'user_score_balance': user_score_balance,
'form': form,
})
@ -92,7 +94,11 @@ class WithDrawCreate(CreateView):
def form_invalid(self, form):
if self.request.is_ajax():
return JsonResponse(form.errors, status=400)
data = {
'errors': form.errors,
'status': 'error',
}
return JsonResponse(data)
return super().form_invalid(form)

Loading…
Cancel
Save