# HG changeset patch # User Lennard de Rijk # Date 1233163862 0 # Node ID 26fade94886b374ed5e9c400800e5c8865bb4b28 # Parent 7e10c0654dfb90c187b9aa02934cc8ac568eee5b Changed the Terms Of Service boolean so that it is None as long as the user owning the account has not Agreed to it. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 7e10c0654dfb -r 26fade94886b app/soc/views/models/user.py --- a/app/soc/views/models/user.py Wed Jan 28 16:50:54 2009 +0000 +++ b/app/soc/views/models/user.py Wed Jan 28 17:31:02 2009 +0000 @@ -99,6 +99,19 @@ super(View, self)._editGet(request, entity, form) + def _editPost(self, request, entity, fields): + """See base.View._editPost(). + """ + + if not entity: + # developer is creating a new entity set agrees_to_tos to None + fields['agrees_to_tos'] = None + else: + # editing an existing user so don't change the agrees_to_tos field + fields['agrees_to_tos'] = entity.agrees_to_tos + + super(View, self)._editPost(request, entity, fields) + def getToSExampleText(self): """Returns example_text linking to site-wide ToS, or a warning message. """ diff -r 7e10c0654dfb -r 26fade94886b app/soc/views/models/user_self.py --- a/app/soc/views/models/user_self.py Wed Jan 28 16:50:54 2009 +0000 +++ b/app/soc/views/models/user_self.py Wed Jan 28 17:31:02 2009 +0000 @@ -155,7 +155,19 @@ """ # fill in the account field with the current User - fields['account'] = users.User() + fields['account'] = users.User() + + # special actions if there is no ToS present + s_logic = model_logic.site.logic + site_tos = s_logic.getToS(s_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['agrees_to_tos'] = None + else: + # editing an existing user so don't change the agrees_to_tos field + fields['agrees_to_tos'] = entity.agrees_to_tos super(View, self)._editPost(request, entity, fields)