#403 Add index page
Merged 3 years ago by lsedlar. Opened 3 years ago by hlin.
hlin/odcs master  into  master

<a class="font-weight-bold ml-2" href="/fork/hlin/odcs/blob/54b09d7d3725c66aa0bc8b9ab92510869ad11365/f/server/odcs/server/templates/index.html" title="View file as of 54b09d7">server/odcs/server/templates/index.html</a>
<div class="btn btn-outline-success disabled opacity-100 border-0 font-weight-bold"> file added </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+16</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/fork/hlin/odcs/blob/54b09d7d3725c66aa0bc8b9ab92510869ad11365/f/server/odcs/server/templates/index.html" title="View file as of 54b09d7"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_1"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -0,0 +1,16 @@ 

+ <!DOCTYPE html>

+ <html lang="en">

+   <head>

+     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

+     <title>On Demand Compose Service</title>

+   </head>

+   <body>

+     <h1>On Demand Compose Service</h1>

+     <p>

+     The ODCS (On Demand Compose Service) is a service that generates temporary

+     composes using REST API calls. It is an open source project available at

+     <a href="https://pagure.io/odcs">https://pagure.io/odcs</a>.

+     </p>

+     <h3><a href="/composes">Composes List</a></h3>

+   </body>

+ </html>

<a class="font-weight-bold ml-2" href="/fork/hlin/odcs/blob/318a49bc4f843b79be2fd02518142324fda3fd67/f/server/odcs/server/views.py" title="View file as of 318a49b">server/odcs/server/views.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+11</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/fork/hlin/odcs/blob/318a49bc4f843b79be2fd02518142324fda3fd67/f/server/odcs/server/views.py" title="View file as of 318a49b"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_2"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -23,8 +23,8 @@ 

  

  import datetime

  

- from flask.views import MethodView

- from flask import request, jsonify, g

+ from flask.views import MethodView, View

+ from flask import render_template, request, jsonify, g

  from werkzeug.exceptions import BadRequest

  

  from odcs.server import app, db, log, conf, version
@@ -584,6 +584,14 @@ 

          return jsonify(json), 200

  

  

+ class Index(View):

+ 

+     methods = ['GET']

+ 

+     def dispatch_request(self):

+         return render_template('index.html')

+ 

+ 

  def register_api_v1():

      """ Registers version 1 of ODCS API. """

      composes_view = ODCSAPI.as_view('composes')
@@ -603,4 +611,5 @@ 

              raise ValueError("Unhandled API key: %s." % key)

  

  

+ app.add_url_rule("/", view_func=Index.as_view("index"))

  register_api_v1()

<a class="font-weight-bold ml-2" href="/fork/hlin/odcs/blob/b0211226687dcb3956436664535f5fcac29921bf/f/server/tests/test_views.py" title="View file as of b021122">server/tests/test_views.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+7</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/fork/hlin/odcs/blob/b0211226687dcb3956436664535f5fcac29921bf/f/server/tests/test_views.py" title="View file as of b021122"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_3"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -266,6 +266,13 @@ 

              db.session.add(self.c2)

              db.session.commit()

  

+     def test_index(self):

+         rv = self.client.get('/')

+         self.assertEqual(rv.status_code, 200)

+         self.assertEqual(rv.content_type, 'text/html; charset=utf-8')

+         data = rv.get_data(as_text=True)

+         self.assertIn('On Demand Compose Service', data)

+ 

      def test_about(self):

          rv = self.client.get('/api/1/about/')

          data = json.loads(rv.get_data(as_text=True))

JIRA: RHELCMP-848
Signed-off-by: Haibo Lin hlin@redhat.com

Will the template be installed correctly from the RPM? I tried installing the package with pip into a fresh virtualenv, and the template got there fine.

"is a service that generates temporary composes using REST API calls. It is an open source project..."

rebased onto ac84660d22caaf1e3aeeb69cad31b01bb945ba01

3 years ago

rebased onto 5e7bcb6

3 years ago

Pull-Request has been merged by lsedlar

3 years ago