|
|
|
@ -143,33 +143,16 @@ class WorkSellDetail(DetailView): |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
context = super().get_context_data(**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['worksell_related'] = WorkSell.objects.exclude(pk=self.get_object().pk)[:5] |
|
|
|
|
|
|
|
context['self_worksell'] = self_worksell |
|
|
|
return context |
|
|
|
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): |
|
|
|
class WorkSellCreateView(BaseMixin, View): |
|
|
|
model = WorkSell |
|
|
|
model = WorkSell |
|
|
|
form_class = WorkSellForm |
|
|
|
form_class = WorkSellForm |
|
|
|
|