Merge branch 'develop' into test
This commit is contained in:
		
						commit
						5da1fe6db4
					
				
					 6 changed files with 3 additions and 156 deletions
				
			
		|  | @ -109,9 +109,7 @@ INSTALLED_APPS = ( | ||||||
|     'dal', |     'dal', | ||||||
|     'dal_select2', |     'dal_select2', | ||||||
| 
 | 
 | ||||||
|     'fluent_comments', |  | ||||||
|     'crispy_forms', |     'crispy_forms', | ||||||
|     'threadedcomments', |  | ||||||
|     'django_comments', |     'django_comments', | ||||||
| 
 | 
 | ||||||
|     'django.contrib.flatpages', |     'django.contrib.flatpages', | ||||||
|  | @ -221,12 +219,6 @@ REST_FRAMEWORK = { | ||||||
|     'PAGE_SIZE': 100 |     'PAGE_SIZE': 100 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Comments |  | ||||||
| 
 |  | ||||||
| COMMENTS_APP = 'fluent_comments' |  | ||||||
| #COMMENTS_APP = 'threadedcomments' |  | ||||||
| FLUENT_COMMENTS_EXCLUDE_FIELDS = ('name', 'email', 'url', 'title') |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| # SECURITY WARNING: keep the secret key used in production secret! | # SECURITY WARNING: keep the secret key used in production secret! | ||||||
| # Create file 'django.secret' in every install (it is not kept in git) | # Create file 'django.secret' in every install (it is not kept in git) | ||||||
|  |  | ||||||
|  | @ -15,9 +15,6 @@ | ||||||
|     <script src="{% static 'js/jquery-1.11.1.js' %}"></script> |     <script src="{% static 'js/jquery-1.11.1.js' %}"></script> | ||||||
|     <script src="{% static 'js/jquery-3.4.1.js' %}"></script> |     <script src="{% static 'js/jquery-3.4.1.js' %}"></script> | ||||||
| 
 | 
 | ||||||
|     <link rel="stylesheet" type="text/css" href="{% static 'fluent_comments/css/ajaxcomments.css' %}" /> |  | ||||||
|     <script type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script> |  | ||||||
| 
 |  | ||||||
|     {# nastavení MathJaxu, aby nahrazoval i matiku obalenou jednoduchými $ #} |     {# nastavení MathJaxu, aby nahrazoval i matiku obalenou jednoduchými $ #} | ||||||
|     <script type="text/x-mathjax-config"> |     <script type="text/x-mathjax-config"> | ||||||
|       MathJax.Hub.Config({ |       MathJax.Hub.Config({ | ||||||
|  |  | ||||||
|  | @ -47,7 +47,6 @@ urlpatterns = [ | ||||||
| 
 | 
 | ||||||
| 	# Comments (interni i verejne) | 	# Comments (interni i verejne) | ||||||
| 	path('comments_dj/', include('django_comments.urls')), | 	path('comments_dj/', include('django_comments.urls')), | ||||||
| 	path('comments_fl/', include('fluent_comments.urls')), |  | ||||||
| 
 | 
 | ||||||
| 	# REST API | 	# REST API | ||||||
| 	path('api/', include(router.urls)), | 	path('api/', include(router.urls)), | ||||||
|  |  | ||||||
|  | @ -23,9 +23,9 @@ | ||||||
| 	</tr> | 	</tr> | ||||||
| 	{% for hodn in hodnoceni %} | 	{% for hodn in hodnoceni %} | ||||||
| 	<tr> | 	<tr> | ||||||
| 		<td>{{ hodn.reseni.cas_doruceni | date:"d.m.Y H:i"}}</td> | 		<td><a href="{% url 'odevzdavatko_resitel_reseni' hodn.reseni.id %}">{{ hodn.reseni.cas_doruceni | date:"d.m.Y H:i"}}</a></td> | ||||||
| 		<td id="problem"><span title="{{ hodn.problem.nazev }}">{{ hodn.problem.nazev | zkrat_nazev_problemu }}</span></td> | 		<td id="problem"><span title="{{ hodn.problem.nazev }}">{{ hodn.problem.nazev | zkrat_nazev_problemu }}</span></td> | ||||||
|         <td><a href="{% url 'odevzdavatko_resitel_reseni' hodn.reseni.id %}">{{ hodn.body|default_if_none:"---" }}</a></td> |         <td>{{ hodn.body|default_if_none:"---" }}</td> | ||||||
| 		<td>{{ hodn.reseni.cas_doruceni | deadline_html }}</td> | 		<td>{{ hodn.reseni.cas_doruceni | deadline_html }}</td> | ||||||
| 	</tr> | 	</tr> | ||||||
| 	{% endfor %} | 	{% endfor %} | ||||||
|  |  | ||||||
|  | @ -34,9 +34,6 @@ django-webpack-loader | ||||||
| django-rest-polymorphic | django-rest-polymorphic | ||||||
| 
 | 
 | ||||||
| # Comments | # Comments | ||||||
| akismet==1.0.1 |  | ||||||
| django-fluent-comments==2.1 |  | ||||||
| django-threadedcomments==1.2 |  | ||||||
| django-contrib-comments==1.9.0 | django-contrib-comments==1.9.0 | ||||||
| 
 | 
 | ||||||
| # debug tools/extensions | # debug tools/extensions | ||||||
|  |  | ||||||
|  | @ -68,144 +68,6 @@ class ObalkovaniView(generic.ListView): | ||||||
| 		context['cislo'] = self.cislo | 		context['cislo'] = self.cislo | ||||||
| 		return context | 		return context | ||||||
| 
 | 
 | ||||||
| class TNLData(object): |  | ||||||
| 	def __init__(self,anode,parent=None, index=None): |  | ||||||
| 		self.node = anode |  | ||||||
| 		self.sernode = vr.TreeNodeSerializer(anode) |  | ||||||
| 		self.children = [] |  | ||||||
| 		self.parent = parent |  | ||||||
| 		self.tema_in_path = False |  | ||||||
| 		self.index = index |  | ||||||
| 
 |  | ||||||
| 		if parent: |  | ||||||
| 			self.tema_in_path = parent.tema_in_path |  | ||||||
| 		if isinstance(anode, m.TemaVCisleNode): |  | ||||||
| 			self.tema_in_path = True |  | ||||||
| 
 |  | ||||||
| 	def add_edit_options(self): |  | ||||||
| 		self.deletable = tnltt.deletable(self) |  | ||||||
| 		self.editable_siblings = tnltt.editableSiblings(self) |  | ||||||
| 		self.editable_children = tnltt.editableChildren(self) |  | ||||||
| 		self.text_only_subtree = tnltt.textOnlySubtree(self) |  | ||||||
| 		self.can_podvesit_za = tnltt.canPodvesitZa(self) |  | ||||||
| 		self.can_podvesit_pred = tnltt.canPodvesitPred(self) |  | ||||||
| 		self.appendable_children = tnltt.appendableChildren(self) |  | ||||||
| 		print("appChld",self.appendable_children) |  | ||||||
| 		if self.parent: |  | ||||||
| 			self.appendable_siblings = tnltt.appendableChildren(self.parent) |  | ||||||
| 		else: |  | ||||||
| 			self.appendable_siblings = [] |  | ||||||
| 	@classmethod |  | ||||||
| 	def public_above(cls, anode): |  | ||||||
| 		""" Returns output of verejne for closest Rocnik, Cislo or Problem above. |  | ||||||
| 		(All of them have method verejne.)""" |  | ||||||
| 		parent = anode # chceme začít už od konkrétního node včetně |  | ||||||
| 		while True: |  | ||||||
| 			rocnik = isinstance(parent, s.RocnikNode) |  | ||||||
| 			cislo = isinstance(parent, s.CisloNode) |  | ||||||
| 			uloha = (isinstance(parent, s.UlohaVzorakNode) or |  | ||||||
| 				isinstance(parent, s.UlohaZadaniNode)) |  | ||||||
| 			tema = isinstance(parent, s.TemaVCisleNode) |  | ||||||
| 
 |  | ||||||
| 			if (rocnik or cislo or uloha or tema) or parent==None: |  | ||||||
| 				break |  | ||||||
| 			else: |  | ||||||
| 				parent = treelib.get_parent(parent) |  | ||||||
| 		if rocnik: |  | ||||||
| 			return parent.rocnik.verejne() |  | ||||||
| 		elif cislo: |  | ||||||
| 			return parent.cislo.verejne() |  | ||||||
| 		elif uloha: |  | ||||||
| 			return parent.uloha.verejne() |  | ||||||
| 		elif tema: |  | ||||||
| 			return parent.tema.verejne() |  | ||||||
| 		elif None: |  | ||||||
| 			print("Existuje TreeNode, který není pod číslem, ročníkem, úlohou" |  | ||||||
| 			"ani tématem. {}".format(anode)) |  | ||||||
| 			return False |  | ||||||
| 
 |  | ||||||
| 	@classmethod |  | ||||||
| 	def all_public_children(cls, anode): |  | ||||||
| 		for ch in treelib.all_children(anode): |  | ||||||
| 			if TNLData.public_above(ch): |  | ||||||
| 				yield ch |  | ||||||
| 			else: |  | ||||||
| 				continue |  | ||||||
| 
 |  | ||||||
| 	@classmethod |  | ||||||
| 	def from_treenode(cls, anode, user, parent=None, index=None): |  | ||||||
| 		if TNLData.public_above(anode) or user.has_perm('auth.org'): |  | ||||||
| 			out = cls(anode,parent,index) |  | ||||||
| 		else: |  | ||||||
| 			raise PermissionDenied() |  | ||||||
| 
 |  | ||||||
| 		if user.has_perm('auth.org'): |  | ||||||
| 			enum_children = enumerate(treelib.all_children(anode)) |  | ||||||
| 		else: |  | ||||||
| 			enum_children = enumerate(TNLData.all_public_children(anode)) |  | ||||||
| 
 |  | ||||||
| 		for (idx,ch) in enum_children: |  | ||||||
| 			outitem = cls.from_treenode(ch, user, out,  idx) |  | ||||||
| 			out.children.append(outitem) |  | ||||||
| 		out.add_edit_options() |  | ||||||
| 		return out |  | ||||||
| 
 |  | ||||||
| 	@classmethod |  | ||||||
| 	def from_tnldata_list(cls, tnllist): |  | ||||||
| 		"""Vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všechna zadaná TNLData""" |  | ||||||
| 		result = cls(None) |  | ||||||
| 		for idx, tnl in enumerate(tnllist): |  | ||||||
| 			result.children.append(tnl) |  | ||||||
| 			tnl.parent = result |  | ||||||
| 			tnl.index = idx |  | ||||||
| 		result.add_edit_options() |  | ||||||
| 		return result |  | ||||||
| 
 |  | ||||||
| 	@classmethod |  | ||||||
| 	def filter_treenode(cls, treenode, predicate): |  | ||||||
| 		tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) |  | ||||||
| 		return TNLData.from_tnldata_list(tnll) |  | ||||||
| 
 |  | ||||||
| 	@classmethod |  | ||||||
| 	def _filter_treenode_recursive(cls, treenode, predicate): |  | ||||||
| 		if predicate(treenode): |  | ||||||
| 			return [cls.from_treenode(treenode)] |  | ||||||
| 		else: |  | ||||||
| 			found = [] |  | ||||||
| 			for tn in treelib.all_children(treenode): |  | ||||||
| 				result = cls.filter_treenode(tn, predicate) |  | ||||||
| 				# Result by v tuhle chvíli měl být seznam TNLDat odpovídající treenodům, jež matchnuly predikát. |  | ||||||
| 				for tnl in result: |  | ||||||
| 					found.append(tnl) |  | ||||||
| 			return found |  | ||||||
| 
 |  | ||||||
| 	def to_json(self): |  | ||||||
| 		#self.node = anode |  | ||||||
| 		#self.children = [] |  | ||||||
| 		#self.parent = parent |  | ||||||
| 		#self.tema_in_path = False |  | ||||||
| 		#self.index = index |  | ||||||
| 		out = {} |  | ||||||
| 		out['node'] = self.sernode.data |  | ||||||
| 		out['children'] = [n.to_json() for n in self.children] |  | ||||||
| 		out['tema_in_path'] = self.tema_in_path |  | ||||||
| 		out['index'] = self.index |  | ||||||
| 		out['deletable'] = self.deletable |  | ||||||
| 		out['editable_siblings'] = self.editable_siblings |  | ||||||
| 		out['editable_children'] = self.editable_children |  | ||||||
| 		out['text_only_subtree'] = self.text_only_subtree |  | ||||||
| 		out['can_podvesit_za'] = self.can_podvesit_za |  | ||||||
| 		out['can_podvesit_pod'] = self.can_podvesit_pred |  | ||||||
| 		out['appendable_children'] = self.appendable_children |  | ||||||
| 		out['appendable_siblings'] = self.appendable_siblings |  | ||||||
| 
 |  | ||||||
| 		return out |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 	def __repr__(self): |  | ||||||
| 		return("TNL({})".format(self.node)) |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| # FIXME: Pozor, níž je ještě jeden ProblemView! | # FIXME: Pozor, níž je ještě jeden ProblemView! | ||||||
| #class ProblemView(generic.DetailView): | #class ProblemView(generic.DetailView): | ||||||
|  | @ -749,7 +611,7 @@ class ClankyResitelView(generic.ListView): | ||||||
| 		queryset = [] | 		queryset = [] | ||||||
| 		skupiny_clanku = group_by_rocnik(clanky) | 		skupiny_clanku = group_by_rocnik(clanky) | ||||||
| 		for skupina in skupiny_clanku: | 		for skupina in skupiny_clanku: | ||||||
| 			skupina.sort(key=lambda clanek: clanek.kod_v_rocniku()) | 			skupina.sort(key=lambda clanek: clanek.kod_v_rocniku) | ||||||
| 			for clanek in skupina: | 			for clanek in skupina: | ||||||
| 				queryset.append(clanek) | 				queryset.append(clanek) | ||||||
| 		return queryset | 		return queryset | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Kateřina Č
						Kateřina Č