浏览代码

Creating template for meetup user data, updating view and meetup.py script

David Leonard 10 年之前
父节点
当前提交
dbca726118

+ 10 - 1
hackathon_starter/hackathon/scripts/meetup.py

@@ -9,5 +9,14 @@ USERDATA = 'https://api.meetup.com/2/member/self/?access_token='
 
 def retrieveUserData(url):
 	req = requests.get(url)
-	return req.content
+	content = json.loads(req.content)
+	filteredData = []
+	data = {}
+	data['name'] = content['name']
+	data['country'] = content['country'].upper()
+	data['city'] = content['city']
+	data['state'] = content['state']
+	data['status'] = content['status']
+	filteredData.append(data)
+	return filteredData
 

+ 39 - 1
hackathon_starter/hackathon/templates/hackathon/meetup.html

@@ -1 +1,39 @@
-{{ data }}
+<!DOCTYPE html>
+<html>
+<body>
+	{% include 'hackathon/base.html' %}
+
+    <h1 class="text-center"> Meetup Profile </h1>
+	<div class="col-lg-12">
+        <div class="table-responsive">
+            <table class="table table-bordered table-hover table-striped tablesorter">
+                <thead>
+                <tr>
+                <th class="header"> Name <i class="icon-sort"></i></th>
+                <th class="header"> State <i class="icon-sort"></i></th>
+                <th class="header"> City <i class="icon-sort"></i></th>
+                <th class="header"> Country <i class="icon-sort"></i></th>
+                <th class="header"> Status <i class="icon-sort"></i></th>
+                </tr>
+            </thead>
+            <tbody>
+
+            {% for key in data %}
+                <tr>
+                    <td>{{ key.name }}</td>
+                    <td>{{ key.state }}</td>
+                    <td>{{ key.city }}</td>
+                    <td>{{ key.country }}</td>
+                    <td>{{ key.status }}</td>
+    			</tr>
+            {% endfor %}
+
+            </tbody>
+            </table>
+        </div>
+    </div>
+
+    
+
+</body>
+</html>

+ 1 - 0
hackathon_starter/hackathon/views.py

@@ -161,6 +161,7 @@ def meetupToken(request):
 def meetupUser(request):
     access_token = MeetupToken.objects.all()[0]
     userData = retrieveUserData('https://api.meetup.com/2/member/self/?access_token=' + str(access_token))
+    print userData
     return render(request, 'hackathon/meetup.html', { 'data': userData })
 
 #################