def update_telechat(request, doc, by, new_telechat_date): # FIXME: reuse function in idrfc/utils.py instead of this one # (need to fix auto-setting returning item problem first though) from ietf.doc.models import TelechatDocEvent on_agenda = bool(new_telechat_date) prev = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") prev_telechat = prev.telechat_date if prev else None prev_agenda = bool(prev_telechat) e = TelechatDocEvent() e.type = "scheduled_for_telechat" e.by = by e.doc = doc e.telechat_date = new_telechat_date if on_agenda != prev_agenda: if on_agenda: e.desc = "Placed on agenda for telechat - %s" % new_telechat_date else: e.desc = "Removed from agenda for telechat" e.save() elif on_agenda and new_telechat_date != prev_telechat: e.desc = "Telechat date has been changed to <b>%s</b> from <b>%s</b>" % ( new_telechat_date, prev_telechat) e.save()
def update_telechat(request, doc, by, new_telechat_date): # FIXME: reuse function in idrfc/utils.py instead of this one # (need to fix auto-setting returning item problem first though) from ietf.doc.models import TelechatDocEvent on_agenda = bool(new_telechat_date) prev = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") prev_telechat = prev.telechat_date if prev else None prev_agenda = bool(prev_telechat) e = TelechatDocEvent() e.type = "scheduled_for_telechat" e.by = by e.doc = doc e.telechat_date = new_telechat_date if on_agenda != prev_agenda: if on_agenda: e.desc = "Placed on agenda for telechat - %s" % new_telechat_date else: e.desc = "Removed from agenda for telechat" e.save() elif on_agenda and new_telechat_date != prev_telechat: e.desc = "Telechat date has been changed to <b>%s</b> from <b>%s</b>" % (new_telechat_date, prev_telechat) e.save()
def update_telechat(request, doc, by, new_telechat_date, new_returning_item=None): on_agenda = bool(new_telechat_date) prev = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") prev_returning = bool(prev and prev.returning_item) prev_telechat = prev.telechat_date if prev else None prev_agenda = bool(prev_telechat) if new_returning_item == None: returning = prev_returning else: returning = new_returning_item if returning == prev_returning and new_telechat_date == prev_telechat: # fully updated, nothing to do return # auto-set returning item _ONLY_ if the caller did not provide a value if ( new_returning_item != None and on_agenda and prev_agenda and new_telechat_date != prev_telechat and prev_telechat < datetime.date.today() and has_same_ballot(doc,prev.telechat_date) ): returning = True e = TelechatDocEvent() e.type = "scheduled_for_telechat" e.by = by e.doc = doc e.rev = doc.rev e.returning_item = returning e.telechat_date = new_telechat_date if on_agenda != prev_agenda: if on_agenda: e.desc = "Placed on agenda for telechat - %s" % (new_telechat_date) else: e.desc = "Removed from agenda for telechat" elif on_agenda and new_telechat_date != prev_telechat: e.desc = "Telechat date has been changed to <b>%s</b> from <b>%s</b>" % ( new_telechat_date, prev_telechat) else: # we didn't reschedule but flipped returning item bit - let's # just explain that if returning: e.desc = "Set telechat returning item indication" else: e.desc = "Removed telechat returning item indication" e.save() from ietf.doc.mails import email_update_telechat email_update_telechat(request, doc, e.desc) return e
def update_telechatREDESIGN(request, doc, by, new_telechat_date, new_returning_item=None): from ietf.doc.models import TelechatDocEvent on_agenda = bool(new_telechat_date) prev = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") prev_returning = bool(prev and prev.returning_item) prev_telechat = prev.telechat_date if prev else None prev_agenda = bool(prev_telechat) returning_item_changed = bool(new_returning_item != None and new_returning_item != prev_returning) if new_returning_item == None: returning = prev_returning else: returning = new_returning_item if returning == prev_returning and new_telechat_date == prev_telechat: # fully updated, nothing to do return # auto-update returning item if (not returning_item_changed and on_agenda and prev_agenda and new_telechat_date != prev_telechat): returning = True e = TelechatDocEvent() e.type = "scheduled_for_telechat" e.by = by e.doc = doc e.returning_item = returning e.telechat_date = new_telechat_date if on_agenda != prev_agenda: if on_agenda: e.desc = "Placed on agenda for telechat - %s" % (new_telechat_date) else: e.desc = "Removed from agenda for telechat" elif on_agenda and new_telechat_date != prev_telechat: e.desc = "Telechat date has been changed to <b>%s</b> from <b>%s</b>" % ( new_telechat_date, prev_telechat) else: # we didn't reschedule but flipped returning item bit - let's # just explain that if returning: e.desc = "Set telechat returning item indication" else: e.desc = "Removed telechat returning item indication" e.save()
def update_telechat(request, doc, by, new_telechat_date, new_returning_item=None): from ietf.doc.models import TelechatDocEvent on_agenda = bool(new_telechat_date) prev = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") prev_returning = bool(prev and prev.returning_item) prev_telechat = prev.telechat_date if prev else None prev_agenda = bool(prev_telechat) if new_returning_item == None: returning = prev_returning else: returning = new_returning_item if returning == prev_returning and new_telechat_date == prev_telechat: # fully updated, nothing to do return # auto-set returning item _ONLY_ if the caller did not provide a value if ( new_returning_item != None and on_agenda and prev_agenda and new_telechat_date != prev_telechat and prev_telechat < datetime.date.today() and has_same_ballot(doc,prev.telechat_date) ): returning = True e = TelechatDocEvent() e.type = "scheduled_for_telechat" e.by = by e.doc = doc e.returning_item = returning e.telechat_date = new_telechat_date if on_agenda != prev_agenda: if on_agenda: e.desc = "Placed on agenda for telechat - %s" % (new_telechat_date) else: e.desc = "Removed from agenda for telechat" elif on_agenda and new_telechat_date != prev_telechat: e.desc = "Telechat date has been changed to <b>%s</b> from <b>%s</b>" % ( new_telechat_date, prev_telechat) else: # we didn't reschedule but flipped returning item bit - let's # just explain that if returning: e.desc = "Set telechat returning item indication" else: e.desc = "Removed telechat returning item indication" e.save() email_update_telechat(request, doc, e.desc)