Repository: fossasia/open-event-server

Issue:
HOME Open-Event main page
#622
- [x] Create event (big button)
- [x] Upcoming events (boxes of events)
- [x] Call for Speakers (boxes of events)



Discussion:

Resolving patch:
diff --git a/open_event/views/views.py b/open_event/views/views.py
--- a/open_event/views/views.py
+++ b/open_event/views/views.py
@@ -29,16 +29,22 @@
 app = Blueprint('', __name__)
 
 
+def chunks(l, n):
+    """Yield successive n-sized chunks from l."""
+    for i in xrange(0, len(l), n):
+        yield l[i:i + n]
+
 @app.route('/', methods=['GET'])
 @auto.doc()
 @cross_origin()
 def get_main_page():
     """Redirect to admin page"""
-    call_for_papers_evs = DataGetter.get_call_for_speakers_events()
-    published_events = DataGetter.get_all_published_events()
+    call_for_papers_evs = DataGetter.get_call_for_speakers_events().all()
+    published_events = DataGetter.get_all_published_events().all()
+    # Provide data as chunks of 6 for the UI to render in a proper way
     return render_template('gentelella/index.html',
-                           call_for_papers_evs=call_for_papers_evs,
-                           published_events=published_events)
+                           call_for_papers_evs=list(chunks(call_for_papers_evs, 6)),
+                           published_events=list(chunks(published_events, 6)))
 
 
 @app.route('/api/v1/event', methods=['GET'])


Test patch:
diff --git a/tests/test_fb_oauth.py b/tests/test_fb_oauth.py
--- a/tests/test_fb_oauth.py
+++ b/tests/test_fb_oauth.py
@@ -33,7 +33,7 @@ def test_user_already_logged_in(self):
             self.app.get(url_for('admin.create_account_after_confirmation_view', hash=data_hash), follow_redirects=True)
             logout(self.app)
             login(self.app, 'email@gmail.com', 'test')
-            self.assertTrue('Create event' in self.app.get('/fCallback/?code=dummy_code&state=dummy_state',
+            self.assertTrue('Open Event' in self.app.get('/fCallback/?code=dummy_code&state=dummy_state',
                                                            follow_redirects=True).data)
             self.assertEqual(self.app.get('/fCallback/?code=dummy_code&state=dummy_state').status_code, 302)
 
diff --git a/tests/test_google_oauth.py b/tests/test_google_oauth.py
--- a/tests/test_google_oauth.py
+++ b/tests/test_google_oauth.py
@@ -26,7 +26,7 @@ def test_user_already_logged_in(self):
             self.app.get(url_for('admin.create_account_after_confirmation_view', hash=data_hash), follow_redirects=True)
             logout(self.app)
             login(self.app, 'email@gmail.com', 'test')
-            self.assertTrue('Create event' in self.app.get('/gCallback/?state=dummy_state&code=dummy_code',
+            self.assertTrue('Open Event' in self.app.get('/gCallback/?state=dummy_state&code=dummy_code',
                                                            follow_redirects=True).data)
             self.assertEqual(self.app.get('/gCallback/?state=dummy_state&code=dummy_code').status_code, 302)
 
diff --git a/tests/test_login.py b/tests/test_login.py
--- a/tests/test_login.py
+++ b/tests/test_login.py
@@ -20,7 +20,7 @@ def test_correct_login(self):
             register(self.app, u'email@gmail.com', u'test')
             logout(self.app)
             rv = login(self.app, 'email@gmail.com', 'test')
-            self.assertTrue("Create event" in rv.data, msg=rv.data)
+            self.assertTrue("Open Event" in rv.data, msg=rv.data)
 
     def test_incorrect_login(self):
         with app.test_request_context():
@@ -32,7 +32,7 @@ def test_incorrect_login(self):
     def test_registration(self):
         with app.test_request_context():
             rv = register(self.app, u'email@gmail.com', u'test')
-            self.assertTrue("Create event" in rv.data)
+            self.assertTrue("Open Event" in rv.data)
 
     def test_logout(self):
         login(self.app, 'email@gmail.com', 'test')