diff --git a/chat/templates/inc-contact-card.html b/chat/templates/inc-contact-card.html index 402b160..fb3ff43 100644 --- a/chat/templates/inc-contact-card.html +++ b/chat/templates/inc-contact-card.html @@ -8,7 +8,7 @@ width: 20px; margin-right: 5px; background-size: cover; - background: url('/static/img/menu2.png') no-repeat 0 0; + background: url('{% static 'img/menu2.png' %}') no-repeat 0 0; } div.icon_mm2 { @@ -17,7 +17,7 @@ width: 20px; margin-right: 5px; background-size: cover; - background: url('/static/img/menu2.png') no-repeat 0 -20px; + background: url('{% static 'img/menu2.png' %}') no-repeat 0 -20px; } @@ -42,10 +42,10 @@ {% url "users:customer-profile-open-projects" pk=contact.pk as contact_url %} {% endif %}
- {% if request.user.is_contractor %} -
- {% else %} + {% if contact.is_contractor %}
+ {% else %} +
{% endif %} {{ contact.username }}
diff --git a/work_sell/templates/worksell_detail.html b/work_sell/templates/worksell_detail.html index 8ab8a77..c85d771 100644 --- a/work_sell/templates/worksell_detail.html +++ b/work_sell/templates/worksell_detail.html @@ -20,7 +20,7 @@ {% endif %} - + {% if object.contractor %}
@@ -28,23 +28,32 @@

{{ object.budget }}

{% if request.user.is_authenticated %} -
+ {% if not self_worksell %} +
купить
- +
Написать сообщение
+ {% else %} + + Это ваш заказ + + {% endif %} + {% endif %} + {% if not self_worksell %}
посмотреть контакты
+ {% endif %}
{% endif %} diff --git a/work_sell/views.py b/work_sell/views.py index b550aae..6d74670 100644 --- a/work_sell/views.py +++ b/work_sell/views.py @@ -143,33 +143,16 @@ class WorkSellDetail(DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + # Своя собственная Работа + self_worksell = False + if self.get_object().id in [obj.id for obj in self.request.user.work_sell.all()]: + self_worksell = True + context['worksell_related'] = WorkSell.objects.exclude(pk=self.get_object().pk)[:5] + context['self_worksell'] = self_worksell return context -# def work_sell_create(request): -# if request.is_ajax(): -# form = WorkSellForm(data=request.POST) -# if form.is_valid(): -# instance = form.save(commit=False) -# # import code; code.interact(local=dict(globals(), **locals())) -# instance.save() -# form.save_m2m() -# images_ids = request.POST.get('images-ids').split(';')[:-1] -# for pk in images_ids: -# picture = Picture.objects.get(pk=pk) -# temp_file = ContentFile(picture.file.read()) -# temp_file.name = picture.file.name -# w_photo = WorkSellPhoto() -# w_photo.img = temp_file -# w_photo.worksell = instance -# w_photo.save() -# data = {'status': 'ok'} -# else: -# data = {'status': 'no', 'form_errors': form.errors} -# return HttpResponse(json.dumps(data), content_type='application/json') - - class WorkSellCreateView(BaseMixin, View): model = WorkSell form_class = WorkSellForm