Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d7b2d0e
files to be reviewed
yashasingh Oct 3, 2017
5ad9407
task 2 for review
yashasingh Oct 5, 2017
cc7ea89
Incomplete file deleted
yashasingh Oct 6, 2017
8133e9a
changes complete
yashasingh Oct 6, 2017
6dd4900
conflict resolved
yashasingh Oct 6, 2017
ef6bda9
conflict resolved
yashasingh Oct 6, 2017
8c861d6
review changes implemented
yashasingh Oct 6, 2017
7bbf540
Sanitized database query
yashasingh Oct 6, 2017
db47853
bug fixes done
yashasingh Oct 6, 2017
97357e5
minor bugs fixed
yashasingh Oct 6, 2017
3553348
minor bugs fixed
yashasingh Oct 6, 2017
863165f
minor fixes
yashasingh Oct 6, 2017
2f5e74d
issues fixed
yashasingh Oct 8, 2017
efcde18
issues fixed
yashasingh Oct 8, 2017
a613a35
issues fixed
yashasingh Oct 8, 2017
f5c41a7
issues resolved
yashasingh Oct 8, 2017
8969f0c
percentile issue resolved
yashasingh Oct 9, 2017
fee5636
merged code
yashasingh Oct 9, 2017
c9e8057
conflict resolved
yashasingh Oct 9, 2017
7659411
minor fixes
yashasingh Oct 9, 2017
66399e5
code cleaned
yashasingh Oct 9, 2017
1581136
merged task1
yashasingh Oct 9, 2017
8df73a2
Merge branch 'devtask2' into complete
yashasingh Oct 9, 2017
a8c655b
minor fixes
yashasingh Oct 9, 2017
4c4a59f
code made deployable
yashasingh Oct 9, 2017
a7fea46
UI updated
yashasingh Oct 11, 2017
f3d082f
minor fixes
yashasingh Oct 11, 2017
75a14b6
code updated
yashasingh Oct 11, 2017
0edfcac
pyc files ignored
yashasingh Oct 12, 2017
cb49836
merged master
yashasingh Oct 12, 2017
6e7a318
Merge branch 'complete' of https://github.com/yashasingh/Review into …
yashasingh Oct 12, 2017
7f5fbe8
minor fix
yashasingh Oct 12, 2017
81cd71a
Minor changes
yashasingh Nov 7, 2017
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
47 changes: 47 additions & 0 deletions App/templates/App/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title> USER CONTRIBUTION SUMMARY </title>
</head>
<body>
<center>
<form method="post">
{% csrf_token %}
Enter Username: <input type="text" name="username">
<br>
<br>
<button type='submit'> Submit </button>
</form>
</center>

<h2>
{% if userid %}
Username = {{username}} <br>
Userid = {{userid}} <br>
<a href="https://phabricator.wikimedia.org/p/{{username}}/"> Profile link </a>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The Phabricator username is not typically the same as the wiki username.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Alright. I added that link to augment to the information. Since I just got to know that phabricator and wiki usernames are not same, I'd rather remove this link. Thank you .

<br>
<br>
<h1>English Edits- </h1><br>
{% endif %}
</h2>
{% for x in contribution %} <!-- Here I traverse all the contributions and display the following div-->
<div>
Title = {{x.title}} <br>
PageID = {{x.pageid}} <br>
RevisionID = {{x.revid}} <br>
ParentID = {{x.parentid}} <br>
ns = {{x.ns}} <br>
Timestamp = {{x.timestamp}} <br>
Comment = {{x.comment}} <br>
Size = {{x.size}} <br>

<a href="https://en.wikipedia.org/w/index.php?title=User:{{x.user}}&diff=prev&oldid={{x.revid}}">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Technically, that's not valid HTML (which is why Github shows it in red); special characters like & or " need to be encoded in attributes. So it should be {{x.user}}&amp;diff. In practice, it works anyway and no one really cares about, so feel free to ignore :) just mentioning for sake of completeness.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Rectified .

click here to revise edit.
</a>

<br><br><br>

<div>
{% endfor %}
</body>
</html>
24 changes: 24 additions & 0 deletions App/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.http import HttpResponse
from django.shortcuts import render
import json
import requests

def index(request):
return HttpResponse("Hello, world. You're at the polls index.")

def main(request):
if(request.method=='POST'):
usr = request.POST['username'] #Here, we get the useranme fetched from html page
URL = "https://en.wikipedia.org/w/api.php?action=query&format=json&list=usercontribs&ucuser="
URL = URL + usr
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What it the username contains a &?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Handled the situation. 👍

r = requests.get(URL) #Recieved data in json-format
lst = json.loads(r.text)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The request might fail (e.g. the API is down and responds with HTTP 503), in which case this won't work.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ok. Will handle this, when response code is other than 200.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done.

sub_lst = lst['query']['usercontribs'] #Contribution data extracted
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The API might respond with an error, in which case this key might not exist. (You can test with a username containing <.)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Resolved.

try:
fetched_user = sub_lst[0]['user']
fetched_user_id = sub_lst[0]['userid']
except:
fetched_user = fetched_user_id = 'No user found'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Or possibly the user was found but has no edits.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

okay , this was a loophole, will handle it 👍

return(render(request,'App/index.html',{'contribution':sub_lst, 'username':fetched_user, 'userid':fetched_user_id})) #Here I send contribution for display on index.html page
else:
return(render(request,'App/index.html',{}))