def _editPost(self, request, entity, fields): """See base.View._editPost(). """ if not entity: # fill in the account field with the current User account = users.User() fields['account'] = account fields['user_id'] = account.user_id() else: fields['account'] = entity.account fields['user_id'] = entity.user_id # special actions if there is no ToS present site_tos = site_logic.getToS(site_logic.getSingleton()) if not site_tos: # there is no Terms of Service set if not entity: # we are a new user so set the agrees_to_tos field to None fields['agreed_to_tos'] = None else: # editing an existing user so no value changes allowed fields['agreed_to_tos'] = entity.agreed_to_tos else: if not entity or not entity.agreed_to_tos: # set the time of agreement fields['agreed_to_tos_on'] = datetime.datetime.now() super(View, self)._editPost(request, entity, fields)
def agreesToSiteToS(self, entity, site_entity): """Returns indication of User's answer to the site-wide Terms of Service. Args: entity: User entity to check for agreement to site-wide ToS Returns: True: no site-wide ToS is currently in effect on the site True: site-wide ToS is in effect *and* User agrees to it (User explicitly answered "Yes") False: site-wide ToS is in effect but User did not agree to it yet """ if not site_logic.getToS(site_entity): # no site-wide ToS in effect, so let the User slide for now return True try: agreed_on = entity.agreed_to_tos_on except db.Error: # return False indicating that answer is missing return False # user has not agreed yet if not agreed_on: return False return True
def editPost(self, request, entity, context, params=None): """Overwrite so we can add the contents of the ToS. For params see base.View.editPost(). """ site_tos = site_logic.getToS(site_logic.getSingleton()) if site_tos: context['tos_contents'] = site_tos.content return super(View, self).editPost(request, entity, context, params=params)