Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to edit user profiles #36

Merged
merged 5 commits into from
Mar 13, 2017

Conversation

ElinSwedin
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Mar 12, 2017

Codecov Report

Merging #36 into develop will increase coverage by 0.17%.
The diff coverage is 98.7%.

@@             Coverage Diff             @@
##           develop      #36      +/-   ##
===========================================
+ Coverage     90.1%   90.28%   +0.17%     
===========================================
  Files           74       74              
  Lines         2739     2800      +61     
  Branches       148      150       +2     
===========================================
+ Hits          2468     2528      +60     
  Misses         248      248              
- Partials        23       24       +1
Impacted Files Coverage Δ
src/foobar/urls.py 60% <ø> (ø)
src/foobar/rest/serializers/account.py 100% <100%> (ø)
src/foobar/admin.py 69.56% <100%> (ø)
src/foobar/forms.py 100% <100%> (ø)
src/foobar/rest/views/account.py 100% <100%> (ø)
src/foobar/tests/test_api.py 100% <100%> (ø)
src/foobar/api.py 95.74% <100%> (+0.34%)
src/foobar/tests/test_views.py 100% <100%> (ø)
src/foobar/models.py 82.6% <100%> (+0.51%)
src/foobar/views.py 93.87% <94.11%> (-0.25%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad176f4...292e295. Read the comment docs.

@kjagiello kjagiello requested review from kjagiello and flaeppe March 12, 2017 09:42
@kjagiello kjagiello added this to the 2.0.0 milestone Mar 12, 2017
return None


def get_account_card(card_id):
Copy link
Member

Choose a reason for hiding this comment

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

I would argue that the name is a bit inaccurate. It sounds like the function is supposed to return the card that is associated with given account, while it is doing the opposite. Maybe get_account_for_card or get_account_by_card instead?

card_obj = get_card(card_id)
if card_obj is not None:
return card_obj.account


def set_account(account_id, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

update_account would be more appropriate here imo.



class EditProfileForm(forms.Form):
name = forms.CharField(label="Account Name", max_length=128)
Copy link
Member

Choose a reason for hiding this comment

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

The labels should be translated.

@@ -0,0 +1,4 @@
{% extends 'profile/base_profile.html' %}
{% block content %}
<div class="account_form" style="text-align:center;">Invalid QRcode <br> Login to get a new </div>
Copy link
Member

Choose a reason for hiding this comment

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

The text here should be translated.

</head>
<body>
<div id="header" >
Profile Details
Copy link
Member

Choose a reason for hiding this comment

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

Translation.

<form class="account_form" method="post" action="">
{% csrf_token %}
{{ form }}
<input type="submit" name="save_changes" value="Save" id="submit_changes" value="{{ account_email }}">
Copy link
Member

Choose a reason for hiding this comment

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

Translation.


def edit_profile(request, token):
form_class = EditProfileForm(request.POST or None)
list(messages.get_messages(request))
Copy link
Member

Choose a reason for hiding this comment

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

Some temporary code that you forgot to remove before committing?

return render(request, "profile/bad_request.html")

if request.method == 'POST':
if 'save_changes' in request.POST:
Copy link
Member

Choose a reason for hiding this comment

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

This check is not needed as there is only one form on the page.

name=form_class.cleaned_data['name'],
email=form_class.cleaned_data['email'])
messages.add_message(request, messages.INFO,
'Successfully Saved')
Copy link
Member

Choose a reason for hiding this comment

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

Translation.


@property
def isComplete(self):
return bool(self.email)
Copy link
Member

Choose a reason for hiding this comment

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

Our convention here is underscore case (i.e. is_complete here)

Copy link
Member

Choose a reason for hiding this comment

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

It is not just our convention. PEP8 does actually say that the underscore case is the preferred naming method.

Method Names and Instance Variables
Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.

Source: https://www.python.org/dev/peps/pep-0008/#id46

Copy link
Member

Choose a reason for hiding this comment

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

Praise PEP8!

token = signing.dumps({'id': str(account_obj.id)})
url = reverse('edit_profile', kwargs={'token': token})
bad_token = reverse('edit_profile', kwargs={'token': 'bad'})
cl = self.client
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason to store the test client into cl?

Otherwise I would argue we want to be explicit(for instance by doing self.client.get).

@kjagiello
Copy link
Member

Now that people can update their e-mail addresses, we should make it possible to see and edit them in the admin panel.

@kjagiello kjagiello changed the title Feature/profile Ability to edit user profiles Mar 13, 2017
@kjagiello
Copy link
Member

🚀

@kjagiello kjagiello merged commit e094b4a into uppsaladatavetare:develop Mar 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants