Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move realname error checking into a multiple boolean, not multiple if…
… expression.

Indicate that a real name is optional on the preferences screen.
  • Loading branch information
LucasSloan committed Dec 22, 2014
commit e3dea7f3e6477a4ad8249bd1cec3537ed4f9a6f1
6 changes: 1 addition & 5 deletions r2/r2/controllers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,8 @@ def POST_update(self, res, email, curpass, realname, password, newpass, verpass)
res._update('curpass', value='')
return

if res._chk_error(errors.BAD_REALNAME_CHARS):
if res._chk_error(errors.BAD_REALNAME_CHARS) or res._chk_error(errors.BAD_REALNAME_SHORT) or res._chk_error(errors.BAD_REALNAME_LONG):
res._focus('real_name')
elif res._chk_error(errors.BAD_REALNAME_SHORT):
res._focus('real_name')
elif res._chk_error(errors.BAD_REALNAME_LONG):
res._focus('real_name')
if realname and realname == c.user.real_name:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong to me. I think you should remove minimum length limits on real names and make it so that an empty string is interpreted as a request to delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried that but it doesn't really work in this case - the update password/email/realname form handles 3 different actions - entering nothing should result in nothing happening. I suspect that people will want to remove their real name rarely enough to make the bizarre syntax acceptable, unless you have a better suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best way to deal with this is to pre-fill the form with the user's current realname, and if they blank it out then delete it from their profile. If it's unchanged then we can infer that the form is being used for something else (password change etc.).

c.user.real_name = None
c.user._commit()
Expand Down
10 changes: 5 additions & 5 deletions r2/r2/templates/prefupdate.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be consistent
## with Exhibit B.
##
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
##
## The Original Code is Reddit.
##
##
## The Original Developer is the Initial Developer. The Initial Developer of
## the Original Code is CondeNet, Inc.
##
##
## All portions of the code written by CondeNet are Copyright (c) 2006-2008
## CondeNet, Inc. All Rights Reserved.
################################################################################
Expand All @@ -39,7 +39,7 @@
</td>
</tr>
<tr>
<td align="right">${_("Real Name")}:</td>
<td align="right">${_("Real Name (optional)")}:</td>
<td><input name="real_name" type="text" value="${hasattr(c.user,'real_name') and c.user.real_name or ''}" title="Enter your current real name to remove it"/></td>
<td>
${error_field("BAD_REALNAME_CHARS")}
Expand Down
2 changes: 1 addition & 1 deletion tasks/manual_test_script
Submodule manual_test_script updated from a49ad9 to c2d154