@ -1,4 +1,5 @@
from django import template
from enum import Enum
import seminar . models as m
register = template . Library ( )
@ -18,45 +19,144 @@ def nodeType(value):
@register . filter
def isRocnik ( value ) :
return isinstance ( value , m . RocnikNode )
return isinstance ( value , m . RocnikNode )
@register . filter
def isCislo ( value ) :
return isinstance ( value , m . CisloNode )
return isinstance ( value , m . CisloNode )
@register . filter
def isCast ( value ) :
return isinstance ( value , m . CastNode )
return isinstance ( value , m . CastNode )
@register . filter
def isText ( value ) :
return isinstance ( value , m . TextNode )
return isinstance ( value , m . TextNode )
@register . filter
def isTemaVCisle ( value ) :
return isinstance ( value , m . TemaVCisleNode )
return isinstance ( value , m . TemaVCisleNode )
@register . filter
def isKonfera ( value ) :
return isinstance ( value , m . KonferaNode )
return isinstance ( value , m . KonferaNode )
@register . filter
def isClanek ( value ) :
return isinstance ( value , m . ClanekNode )
return isinstance ( value , m . ClanekNode )
@register . filter
def isUlohaVzorak ( value ) :
return isinstance ( value , m . UlohaVzorakNode )
return isinstance ( value , m . UlohaVzorakNode )
@register . filter
def isUlohaZadani ( value ) :
return isinstance ( value , m . UlohaZadaniNode )
return isinstance ( value , m . UlohaZadaniNode )
@register . filter
def isPohadka ( value ) :
return isinstance ( value , m . PohadkaNode )
return isinstance ( value , m . PohadkaNode )
@register . filter
def isReseni ( value ) :
return False
# return isinstance(value, m.OtisteneReseniNode)
@register . filter
def isOrgText ( value ) :
return False
# return isinstance(value, m.OrgTextNode)
###
#@register.filter
#def podvesitelneNody(value):
# if isText()
@register . filter
def deletable ( value ) :
if isTemaVCisle ( value ) :
return True
if isOrgText ( value ) :
return True
if isReseni ( value ) :
return True
if isUlohaZadani ( value ) :
return True
if isUlohaVzorak ( value ) :
return True
if isCast ( value ) :
return True
if isText ( value ) :
return True
return False
@register . filter
def editableSiblings ( value ) :
if isCast ( value . node ) :
return True
if isText ( value . node ) :
return True
if isReseni ( value . node ) and value . tema_in_path :
return True
if isUlohaZadani ( value . node ) and value . tema_in_path :
return True
if isUlohaVzorak ( value . node ) and value . tema_in_path :
return True
return False
@register . filter
def editableChildren ( value ) :
if isRocnik ( value . node ) :
return False
if isCislo ( value . node ) :
return False
if isText ( value . node ) :
return False
return True
class NodeTypes ( Enum ) :
ROCNIK = ( ' rocnikNode ' , ' Ročník ' )
CISLO = ( ' cisloNode ' , ' Číslo ' )
CAST = ( ' castNode ' , ' Část ' )
TEXT = ( ' textNode ' , ' Text ' )
TEMAVCISLE = ( ' temaVCisleNode ' , ' Téma v čísle ' )
RESENI = ( ' reseniNode ' , ' Řešení ' )
ULOHAZADANI = ( ' ulohaZadaniNode ' , ' Zadání ' )
ULOHAVZORAK = ( ' ulohaVzorakNode ' , ' Vzorák ' )
POHADKA = ( ' pohadkaNode ' , ' Pohádka ' )
ORGTEXT = ( ' orgText ' , ' Orgtext ' )
@register . filter
def appendableChildren ( value ) :
if isTemaVCisle ( value ) :
return ( NodeTypes . RESENI . value ,
NodeTypes . ULOHAZADANI . value ,
NodeTypes . ULOHAVZORAK . value ,
NodeTypes . CAST . value ,
NodeTypes . TEXT . value ,
)
if isOrgText ( value ) or isReseni ( value ) or isUlohaZadani ( value ) or isUlohaVzorak ( value ) :
return ( NodeTypes . CAST . value ,
NodeTypes . TEXT . value ,
)
if isCast ( value ) :
return appendableChildren ( value . parent )
return None
#@register.filter
#def is(value):
# return
#
# NodeTypes..value,
#@register.filter
#def isOtisteneReseniNode(value):
# return isinstance(value, m.OtisteneReseniNode)
#def is(value):
# return