@ -1,4 +1,5 @@
from django import template
from django import template
from enum import Enum
import seminar . models as m
import seminar . models as m
register = template . Library ( )
register = template . Library ( )
@ -18,45 +19,144 @@ def nodeType(value):
@register . filter
@register . filter
def isRocnik ( value ) :
def isRocnik ( value ) :
return isinstance ( value , m . RocnikNode )
return isinstance ( value , m . RocnikNode )
@register . filter
@register . filter
def isCislo ( value ) :
def isCislo ( value ) :
return isinstance ( value , m . CisloNode )
return isinstance ( value , m . CisloNode )
@register . filter
@register . filter
def isCast ( value ) :
def isCast ( value ) :
return isinstance ( value , m . CastNode )
return isinstance ( value , m . CastNode )
@register . filter
@register . filter
def isText ( value ) :
def isText ( value ) :
return isinstance ( value , m . TextNode )
return isinstance ( value , m . TextNode )
@register . filter
@register . filter
def isTemaVCisle ( value ) :
def isTemaVCisle ( value ) :
return isinstance ( value , m . TemaVCisleNode )
return isinstance ( value , m . TemaVCisleNode )
@register . filter
@register . filter
def isKonfera ( value ) :
def isKonfera ( value ) :
return isinstance ( value , m . KonferaNode )
return isinstance ( value , m . KonferaNode )
@register . filter
@register . filter
def isClanek ( value ) :
def isClanek ( value ) :
return isinstance ( value , m . ClanekNode )
return isinstance ( value , m . ClanekNode )
@register . filter
@register . filter
def isUlohaVzorak ( value ) :
def isUlohaVzorak ( value ) :
return isinstance ( value , m . UlohaVzorakNode )
return isinstance ( value , m . UlohaVzorakNode )
@register . filter
@register . filter
def isUlohaZadani ( value ) :
def isUlohaZadani ( value ) :
return isinstance ( value , m . UlohaZadaniNode )
return isinstance ( value , m . UlohaZadaniNode )
@register . filter
@register . filter
def isPohadka ( value ) :
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
#@register.filter
#def isOtisteneReseniNode(value):
#def is(value):
# return isinstance(value, m.OtisteneReseniNode)
# return