Ejemplo n.º 1
0
def close(request):
    cmts = []
    allcmts = Comment.objects.order_by("-id")[0:50]
    groupSize = 10
    group = []
    for i, x in enumerate(allcmts):
        if i % groupSize == 0:
            if i > 0:
                cmts.append(group)
            group = []
        group.append(x.context + utils.getPdate(x.date))
    if group:
        cmts.append(group)
    return render_to_response("close.html", {"cmts": cmts})
Ejemplo n.º 2
0
def close(request):
    cmts = []
    allcmts = Comment.objects.order_by("-id")[0:50]
    groupSize = 10
    group = []
    for i, x in enumerate(allcmts):
        if i%groupSize == 0:
            if i>0:
                cmts.append(group)
            group = []
        group.append(x.context + utils.getPdate(x.date))
    if group:
        cmts.append(group)
    return render_to_response("close.html", {"cmts":cmts})
Ejemplo n.º 3
0
def comment(request, date=None):
    res = ""
    if request.POST.has_key("context") and len(request.POST["context"])>0:
        maxLen = Comment._meta.get_field("context").max_length
        author = utils.escapeHtml(request.POST["author"])
        if len(author) == 0:
            author = utils.getMaskedIp(request)
        if author == "admin@mars":
            res = "<dt><font color=\"orange\">%s</font></dt>" % "admin"
        else:
            res = "<dt>%s</dt>" % author
        context = utils.escapeHtml(request.POST["context"].replace("\r\n", "\n"))
        for line in context.split("\n"):
            res += "\r\n<dd>%s</dd>" % line
        res = res[0:maxLen-55]
        context = res
        parent = utils.getToday()
        cmt = Comment(author=author, context=context, parent=parent)
        cmt.save()
        res += utils.getPdate(cmt.date)
    return HttpResponse(res)
Ejemplo n.º 4
0
def comment(request, date=None):
    res = ""
    if request.POST.has_key("context") and len(request.POST["context"]) > 0:
        maxLen = Comment._meta.get_field("context").max_length
        author = utils.escapeHtml(request.POST["author"])
        if len(author) == 0:
            author = utils.getMaskedIp(request)
        if author == "admin@mars":
            res = "<dt><font color=\"orange\">%s</font></dt>" % "admin"
        else:
            res = "<dt>%s</dt>" % author
        context = utils.escapeHtml(request.POST["context"].replace(
            "\r\n", "\n"))
        for line in context.split("\n"):
            res += "\r\n<dd>%s</dd>" % line
        res = res[0:maxLen - 55]
        context = res
        parent = utils.getToday()
        cmt = Comment(author=author, context=context, parent=parent)
        cmt.save()
        res += utils.getPdate(cmt.date)
    return HttpResponse(res)
Ejemplo n.º 5
0
def onDate(request, date=None, page=None):
    if date == None:
        date = utils.getToday()
    if page and page != "lunch" and page != "dinner":
        return HttpResponseNotFound(utils.notFound % request.path_info)
    lunch9, lunch22, dinner9, dinner22 = utils.getFileLists(date)
    lunch9cnt, lunch22cnt, dinner9cnt, dinner22cnt = {}, {}, {}, {}
    folders = utils.getDateList()
    dateObj = utils.getDateObj(date)
    useSp = dateObj > utils.dateSp  # sharepoint
    if not useSp:
        for file in lunch9:
            lunch9cnt[file] = getPicCnt(file)
        for file in lunch22:
            lunch22cnt[file] = getPicCnt(file)
        for file in dinner9:
            dinner9cnt[file] = getPicCnt(file)
        for file in dinner22:
            dinner22cnt[file] = getPicCnt(file)
    showDinner = (dinner9cnt
                  or dinner22cnt) and utils.getNowH() >= utils.dinnerH
    if page == "lunch":
        showDinner = False
    elif page == "dinner":
        showDinner = True
    cmts = []
    allcmts = Comment.objects.order_by("-id")[0:50]
    groupSize = 10
    group = []
    for i, x in enumerate(allcmts):
        if i % groupSize == 0:
            if i > 0:
                cmts.append(group)
            group = []
        group.append(x.context + utils.getPdate(x.date))
    if group:
        cmts.append(group)
    if not useSp:
        return render_to_response(
            "index.html", {
                "folders": folders,
                "date": date,
                "lunch9cnt": lunch9cnt,
                "lunch22cnt": lunch22cnt,
                "dinner9cnt": dinner9cnt,
                "dinner22cnt": dinner22cnt,
                "cmts": cmts,
                "showDinner": showDinner
            })
    isToday = date == utils.getToday()
    lunch9info, lunch22info, dinner9info, dinner22info = {}, {}, {}, {}
    for file in lunch9:
        lunch9info[file] = getDishInfo(file, date)
    for file in lunch22:
        lunch22info[file] = getDishInfo(file, date)
    for file in dinner9:
        dinner9info[file] = getDishInfo(file, date)
    for file in dinner22:
        dinner22info[file] = getDishInfo(file, date)
    meal = ""
    if isToday and (lunch9info or lunch22info or dinner9info or dinner22info):
        if utils.getNowH() >= utils.dinnerH:
            meal = "dinner"
        else:
            meal = "lunch"
    showDinner = (dinner9info
                  or dinner22info) and utils.getNowH() >= utils.dinnerH
    if page == "lunch":
        showDinner = False
    elif page == "dinner":
        showDinner = True
    polls = getOpenPolls()
    dateTtl = dateObj.strftime("%m.%d")
    return render_to_response(
        "indexSp.html", {
            "folders": folders,
            "date": date,
            "meal": meal,
            "lunch9info": lunch9info,
            "lunch22info": lunch22info,
            "dinner9info": dinner9info,
            "dinner22info": dinner22info,
            "cmts": cmts,
            "showDinner": showDinner,
            "polls": polls,
            "dateTtl": dateTtl
        })
Ejemplo n.º 6
0
def onDate(request, date=None, page=None):
    if date == None:
        date = utils.getToday()
    if page and page!="lunch" and page!="dinner":
        return HttpResponseNotFound(utils.notFound % request.path_info)
    lunch9, lunch22, dinner9, dinner22 = utils.getFileLists(date)
    lunch9cnt, lunch22cnt, dinner9cnt, dinner22cnt = {}, {}, {}, {}
    folders = utils.getDateList()
    dateObj = utils.getDateObj(date)
    useSp = dateObj > utils.dateSp  # sharepoint
    if not useSp:
        for file in lunch9:
            lunch9cnt[file] = getPicCnt(file)
        for file in lunch22:
            lunch22cnt[file] = getPicCnt(file)
        for file in dinner9:
            dinner9cnt[file] = getPicCnt(file)
        for file in dinner22:
            dinner22cnt[file] = getPicCnt(file)
    showDinner = (dinner9cnt or dinner22cnt) and utils.getNowH() >= utils.dinnerH
    if page=="lunch":
        showDinner = False
    elif page=="dinner":
        showDinner = True
    cmts = []
    allcmts = Comment.objects.order_by("-id")[0:50]
    groupSize = 10
    group = []
    for i, x in enumerate(allcmts):
        if i%groupSize == 0:
            if i>0:
                cmts.append(group)
            group = []
        group.append(x.context + utils.getPdate(x.date))
    if group:
        cmts.append(group)
    if not useSp:
        return render_to_response("index.html", {"folders":folders, "date":date, 
                                             "lunch9cnt":lunch9cnt, "lunch22cnt":lunch22cnt, 
                                             "dinner9cnt":dinner9cnt, "dinner22cnt":dinner22cnt,
                                             "cmts":cmts, "showDinner":showDinner})
    isToday = date==utils.getToday()
    lunch9info, lunch22info, dinner9info, dinner22info = {}, {}, {}, {}
    for file in lunch9:
        lunch9info[file] = getDishInfo(file, date)
    for file in lunch22:
        lunch22info[file] = getDishInfo(file, date)
    for file in dinner9:
        dinner9info[file] = getDishInfo(file, date)
    for file in dinner22:
        dinner22info[file] = getDishInfo(file, date)
    meal = ""
    if isToday and (lunch9info or lunch22info or dinner9info or dinner22info):
        if utils.getNowH() >= utils.dinnerH:
            meal = "dinner"
        else:
            meal = "lunch"
    showDinner = (dinner9info or dinner22info) and utils.getNowH() >= utils.dinnerH
    if page=="lunch":
        showDinner = False
    elif page=="dinner":
        showDinner = True
    polls = getOpenPolls()
    dateTtl = dateObj.strftime("%m.%d")
    return render_to_response("indexSp.html", {"folders":folders, "date":date, "meal":meal,
                                             "lunch9info":lunch9info, "lunch22info":lunch22info, 
                                             "dinner9info":dinner9info, "dinner22info":dinner22info, 
                                             "cmts":cmts, "showDinner":showDinner,
                                             "polls":polls, "dateTtl":dateTtl})