示例#1
0
def check_grid_pub_exp_dates(draft):
    """Returns a dictionary of Errors and Warnings for DesignerActions in the grid whose pub_date or
     exp_date are not in the challenge."""
    ret = {}
    ret[_ERRORS] = []
    ret[_WARNINGS] = []
    challenge_start = challenge_mgr.get_challenge_start()
    challenge_end = challenge_mgr.get_challenge_end()
    for loc in DesignerGrid.objects.filter(draft=draft):
        if loc.action.pub_date > challenge_end.date():
            message = "Publication Date %s after end of Challenge %s" % (loc.action.pub_date, \
                                                                         challenge_end.date())
            ret[_ERRORS].append(Error(message=message, \
                                       action=loc.action))
        if loc.action.expire_date and \
            loc.action.expire_date < \
            challenge_start.date():
            message = "Expiration date %s is before beginning of Challenge %s" % \
            (loc.action.expire_date, challenge_start.date())
            ret[_ERRORS].append(Error(message=message, \
                                       action=loc.action))


#         if not __is_in_rounds(datetime.combine(loc.action.pub_date, time(0, 0))):
#             message = "Publication Date %s isn't in a round" % loc.action.pub_date
#             ret[_WARNINGS].append(Warn(message=message, \
#                                         action=loc.action))
#         if loc.action.expire_date and not \
#             __is_in_rounds(datetime.combine(loc.action.expire_date, time(0, 0))):
#             message = "Expiration Date isn't in a round" % loc.action.expire_date
#             ret[_WARNINGS].append(Warn(message=message, \
#                                         action=loc.action))
    return ret
示例#2
0
def check_pub_exp_dates(draft):
    """Returns a dictionary of Errors and Warnings for DesignerActions whose pub_date or
     exp_date are not in the challenge."""
    ret = {}
    ret[_ERRORS] = []
    ret[_WARNINGS] = []
    challenge_start = challenge_mgr.get_challenge_start()
    challenge_end = challenge_mgr.get_challenge_end()
    for action in DesignerAction.objects.filter(draft=draft):
        if action.pub_date > challenge_end.date():
            ret[_ERRORS].append(Error(message="Publication Date after end of Challenge", \
                                       action=action))
        if action.expire_date and \
            datetime.combine(action.expire_date, time(0, 0)) < \
            challenge_start.date():
            ret[_ERRORS].append(Error(message="Expiration date before beginning of Challenge", \
                                       action=action))
        if not __is_in_rounds(datetime.combine(action.pub_date, time(0, 0))):
            ret[_WARNINGS].append(Warn(message="Publication Date isn't in a round", \
                                        action=action))
        if action.expire_date and not \
            __is_in_rounds(datetime.combine(action.expire_date, time(0, 0))):
            ret[_WARNINGS].append(Warn(message="Expiration Date isn't in a round", \
                                        action=action))
    return ret
示例#3
0
文件: gcc.py 项目: csdl/makahiki
def check_grid_pub_exp_dates(draft):
    """Returns a dictionary of Errors and Warnings for DesignerActions in the grid whose pub_date or
     exp_date are not in the challenge."""
    ret = {}
    ret[_ERRORS] = []
    ret[_WARNINGS] = []
    challenge_start = challenge_mgr.get_challenge_start()
    challenge_end = challenge_mgr.get_challenge_end()
    for loc in DesignerGrid.objects.filter(draft=draft):
        if loc.action.pub_date > challenge_end.date():
            message = "Publication Date %s after end of Challenge %s" % (loc.action.pub_date, \
                                                                         challenge_end.date())
            ret[_ERRORS].append(Error(message=message, \
                                       action=loc.action))
        if loc.action.expire_date and \
            loc.action.expire_date < \
            challenge_start.date():
            message = "Expiration date %s is before beginning of Challenge %s" % \
            (loc.action.expire_date, challenge_start.date())
            ret[_ERRORS].append(Error(message=message, \
                                       action=loc.action))
#         if not __is_in_rounds(datetime.combine(loc.action.pub_date, time(0, 0))):
#             message = "Publication Date %s isn't in a round" % loc.action.pub_date
#             ret[_WARNINGS].append(Warn(message=message, \
#                                         action=loc.action))
#         if loc.action.expire_date and not \
#             __is_in_rounds(datetime.combine(loc.action.expire_date, time(0, 0))):
#             message = "Expiration Date isn't in a round" % loc.action.expire_date
#             ret[_WARNINGS].append(Warn(message=message, \
#                                         action=loc.action))
    return ret
示例#4
0
文件: gcc.py 项目: csdl/makahiki
def check_pub_exp_dates(draft):
    """Returns a dictionary of Errors and Warnings for DesignerActions whose pub_date or
     exp_date are not in the challenge."""
    ret = {}
    ret[_ERRORS] = []
    ret[_WARNINGS] = []
    challenge_start = challenge_mgr.get_challenge_start()
    challenge_end = challenge_mgr.get_challenge_end()
    for action in DesignerAction.objects.filter(draft=draft):
        if action.pub_date > challenge_end.date():
            ret[_ERRORS].append(Error(message="Publication Date after end of Challenge", \
                                       action=action))
        if action.expire_date and \
            datetime.combine(action.expire_date, time(0, 0)) < \
            challenge_start.date():
            ret[_ERRORS].append(Error(message="Expiration date before beginning of Challenge", \
                                       action=action))
        if not __is_in_rounds(datetime.combine(action.pub_date, time(0, 0))):
            ret[_WARNINGS].append(Warn(message="Publication Date isn't in a round", \
                                        action=action))
        if action.expire_date and not \
            __is_in_rounds(datetime.combine(action.expire_date, time(0, 0))):
            ret[_WARNINGS].append(Warn(message="Expiration Date isn't in a round", \
                                        action=action))
    return ret
示例#5
0
def __is_in_challenge(date):
    """Returns True if the given date is between the Challenge start and end dates."""
    if date:
        start = challenge_mgr.get_challenge_start()
        end = challenge_mgr.get_challenge_end()
        return date >= start and date <= end
    else:
        return False
示例#6
0
文件: gcc.py 项目: csdl/makahiki
def __is_in_challenge(date):
    """Returns True if the given date is between the Challenge start and end dates."""
    if date:
        start = challenge_mgr.get_challenge_start()
        end = challenge_mgr.get_challenge_end()
        return date >= start and date <= end
    else:
        return False
示例#7
0
def check_pub_exp_dates(draft):
    """Returns a list of DesignerAction slugs whose pub_date or exp_date are not in the
     challenge."""
    ret = []
    trees = build_designer_trees(draft)
    challenge_start = challenge_mgr.get_challenge_start()
    challenge_end = challenge_mgr.get_challenge_end()
    # check only DesignerActions in the grid?
    for action in DesignerAction.objects.filter(draft=draft):
        if action.pub_date > challenge_end.date() or (action.expire_date and \
                                                      action.expire_date < challenge_start.date()):
            for k in list(trees):
                tree = trees[k]
                node = tree.get_node(action.slug)
                if node:
                    ret.append(node.admin_link())
    return ret
示例#8
0
文件: gcc.py 项目: csdl/makahiki
def check_grid_event_dates(draft):
    """Returns a list of Errors for DesignerEvents in the grid whose event_date isn't in the
    challenge or isn't during a round."""
    ret = []
    for loc in DesignerGrid.objects.filter(draft=draft):
        if loc.action.type == 'event':
            event = smartgrid_mgr.get_designer_action(draft=draft, slug=loc.action.slug)
            if not __is_in_rounds(event.event_date):
                if event.event_date:
                    message = "Event date %s isn't in a round" % event.event_date.date()
                else:
                    message = "Event doesn't have an event date."
                ret.append(Error(message=message, action=event))
            if not __is_in_challenge(event.event_date):
                if event.event_date:
                    message = "Event date %s isn't in the challenge %s - %s" % \
                    (event.event_date.date(), challenge_mgr.get_challenge_start().date(), \
                     challenge_mgr.get_challenge_end().date())
                else:
                    message = "Event doesn't have an event date."
                ret.append(Error(message=message, action=event))
    return ret
示例#9
0
def check_grid_event_dates(draft):
    """Returns a list of Errors for DesignerEvents in the grid whose event_date isn't in the
    challenge or isn't during a round."""
    ret = []
    for loc in DesignerGrid.objects.filter(draft=draft):
        if loc.action.type == 'event':
            event = smartgrid_mgr.get_designer_action(draft=draft,
                                                      slug=loc.action.slug)
            if not __is_in_rounds(event.event_date):
                if event.event_date:
                    message = "Event date %s isn't in a round" % event.event_date.date(
                    )
                else:
                    message = "Event doesn't have an event date."
                ret.append(Error(message=message, action=event))
            if not __is_in_challenge(event.event_date):
                if event.event_date:
                    message = "Event date %s isn't in the challenge %s - %s" % \
                    (event.event_date.date(), challenge_mgr.get_challenge_start().date(), \
                     challenge_mgr.get_challenge_end().date())
                else:
                    message = "Event doesn't have an event date."
                ret.append(Error(message=message, action=event))
    return ret