Čistka nepotřebných věcí
This commit is contained in:
		
							parent
							
								
									0f1cd2e32a
								
							
						
					
					
						commit
						2f30d8d27f
					
				
					 1 changed files with 0 additions and 67 deletions
				
			
		|  | @ -51,7 +51,6 @@ class KorekturySeskupeneListView(KorekturyAktualniListView): | ||||||
| 
 | 
 | ||||||
| ### Korektury | ### Korektury | ||||||
| class KorekturyView(generic.TemplateView): | class KorekturyView(generic.TemplateView): | ||||||
| 	model = Oprava |  | ||||||
| 	template_name = 'korektury/korekturovatko/htmlstrana.html' | 	template_name = 'korektury/korekturovatko/htmlstrana.html' | ||||||
| 
 | 
 | ||||||
| 	def setup(self, request, *args, **kwargs): | 	def setup(self, request, *args, **kwargs): | ||||||
|  | @ -59,78 +58,12 @@ class KorekturyView(generic.TemplateView): | ||||||
| 		self.pdf_id = self.kwargs["pdf"] | 		self.pdf_id = self.kwargs["pdf"] | ||||||
| 		self.pdf = get_object_or_404(KorekturovanePDF, id=self.pdf_id) | 		self.pdf = get_object_or_404(KorekturovanePDF, id=self.pdf_id) | ||||||
| 
 | 
 | ||||||
| 	def post(self, request, *args, **kwargs): |  | ||||||
| 		q = request.POST |  | ||||||
| 
 |  | ||||||
| 		# prirazeni autora podle prihlaseni |  | ||||||
| 		autor_user = request.user |  | ||||||
| 		# pokud existuje ucet (user), ale neni to organizator = 403 |  | ||||||
| 		autor = Organizator.objects.filter(osoba__user=autor_user).first() |  | ||||||
| 		if not autor: |  | ||||||
| 			return HttpResponseForbidden() |  | ||||||
| 
 |  | ||||||
| 		action = q.get('action') |  | ||||||
| 		if (action == ''):  # Přidej |  | ||||||
| 			x = int(q.get('x')) |  | ||||||
| 			y = int(q.get('y')) |  | ||||||
| 			text = q.get('txt') |  | ||||||
| 			strana = int(q.get('img-id')[4:]) |  | ||||||
| 			op = Oprava(x=x,y=y, strana=strana, pdf=self.pdf) |  | ||||||
| 			op.save() |  | ||||||
| 			kom = Komentar(oprava=op,autor=autor,text=text) |  | ||||||
| 			kom.save() |  | ||||||
| 			send_email_notification_komentar(op, autor, request) |  | ||||||
| 		elif (action == 'del'): |  | ||||||
| 			id = int(q.get('id')) |  | ||||||
| 			op = Oprava.objects.get(id=id) |  | ||||||
| 			for k in Komentar.objects.filter(oprava=op): |  | ||||||
| 				k.delete() |  | ||||||
| 			op.delete() |  | ||||||
| 		elif action in Oprava.STATUS.values: |  | ||||||
| 			id = int(q.get('id')) |  | ||||||
| 			op = Oprava.objects.get(id=id) |  | ||||||
| 			op.status = action |  | ||||||
| 			op.save() |  | ||||||
| 		elif (action == 'comment'): |  | ||||||
| 			id = int(q.get('id')) |  | ||||||
| 			op = Oprava.objects.get(id=id) |  | ||||||
| 			text = q.get('txt') |  | ||||||
| 			kom = Komentar(oprava=op,autor=autor,text=text) |  | ||||||
| 			kom.save() |  | ||||||
| 			send_email_notification_komentar(op, autor, request) |  | ||||||
| 		elif (action == 'update-comment'): |  | ||||||
| 			id = int(q.get('id')) |  | ||||||
| 			kom = Komentar.objects.get(id=id) |  | ||||||
| 			text = q.get('txt') |  | ||||||
| 			kom.text = text |  | ||||||
| 			kom.autor = autor |  | ||||||
| 			kom.save() |  | ||||||
| 		elif (action == 'del-comment'): |  | ||||||
| 			id = int(q.get('id')) |  | ||||||
| 			kom = Komentar.objects.get(id=id) |  | ||||||
| 			kom.delete() |  | ||||||
| 		elif (action == 'set-state'): |  | ||||||
| 			status = q.get('state') |  | ||||||
| 			assert status in KorekturovanePDF.STATUS.values |  | ||||||
| 			self.pdf.status = status |  | ||||||
| 			self.pdf.save() |  | ||||||
| 		context = self.get_context_data() |  | ||||||
| 		context['autor'] = autor |  | ||||||
| 		return render(request, 'korektury/korekturovatko/htmlstrana.html', context) |  | ||||||
| 
 | 
 | ||||||
| 	def get_context_data(self, **kwargs): | 	def get_context_data(self, **kwargs): | ||||||
| 		context = super().get_context_data(**kwargs) | 		context = super().get_context_data(**kwargs) | ||||||
| 		context['pdf'] = self.pdf | 		context['pdf'] = self.pdf | ||||||
| 		context['img_prefix'] = self.pdf.get_prefix() | 		context['img_prefix'] = self.pdf.get_prefix() | ||||||
| 		context['img_path'] = settings.KOREKTURY_IMG_DIR |  | ||||||
| 		context['img_indexes'] = range(self.pdf.stran) | 		context['img_indexes'] = range(self.pdf.stran) | ||||||
| 		opravy = Oprava.objects.filter(pdf=self.pdf_id) |  | ||||||
| 
 |  | ||||||
| 		strany = set(o.strana for o in opravy) |  | ||||||
| 		opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany] |  | ||||||
| 		context['opravy_strany'] = opravy_na_stranu |  | ||||||
| 		 |  | ||||||
| 		context['opravy'] = opravy |  | ||||||
| 
 | 
 | ||||||
| 		context['tagy'] = KorekturaTag.objects.all() | 		context['tagy'] = KorekturaTag.objects.all() | ||||||
| 		return context | 		return context | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue