Browse Source

add project overview

master
Burathar 4 years ago
parent
commit
3f018733cc
  1. 24
      biscd/biscd/models/project.py
  2. 14
      biscd/biscd/routes.py
  3. 4
      biscd/biscd/templates/index.html
  4. 29
      biscd/biscd/templates/project.html
  5. 6
      installation-files/projects_example.yaml

24
biscd/biscd/models/project.py

@ -7,15 +7,15 @@ class Project:
storage = {} storage = {}
def __init__(self, name): def __init__(self, name, branche='master'):
self.name = name self.name = name
self.branche = 'master' self.branche = branche
@property @property
def config_dict(self): def config_dict(self):
dictionary = self.__dict__.copy() project_dict = self.__dict__.copy()
dictionary.pop('name') project_dict.pop('name')
return {self.name: dictionary} return {self.name: project_dict}
def save(self): def save(self):
projects = self._get_projects_from_file() projects = self._get_projects_from_file()
@ -28,10 +28,18 @@ class Project:
@classmethod @classmethod
def get(cls, name): def get(cls, name):
project = cls._get_projects_from_file().get(name) project_dict = next(project for project in cls._get_projects_from_file() if [*project][0] == name)
if project is None: if project_dict is None:
return None return None
return cls(project.get('name')) project_name = [*project_dict][0]
project_dict = project_dict.get(project_name)
project_dict['name'] = project_name
project = cls('placeholder')
project.__dict__ = project_dict
return project
@classmethod @classmethod
def list(cls): def list(cls):

14
biscd/biscd/routes.py

@ -1,6 +1,6 @@
from flask import render_template, flash from flask import render_template, flash, abort
from biscd import app from biscd import app
from .models.project import Project from .models import Project
from .froms import NewProjectForm from .froms import NewProjectForm
@app.route('/', methods=['GET', 'POST']) @app.route('/', methods=['GET', 'POST'])
@ -12,4 +12,12 @@ def index():
project.save() project.save()
flash('You added a project!') flash('You added a project!')
project_names = Project.list() project_names = Project.list()
return render_template('index.html', form=form, projects=project_names) return render_template('index.html', form=form, project_names=project_names)
@app.route('/project/<project_name>', methods=['GET', 'POST'])
def project_dashboard(project_name):
print(project_name)
project = Project.get(project_name)
if project is None:
abort(404)
return render_template('project.html', project=project)

4
biscd/biscd/templates/index.html

@ -6,9 +6,9 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
<tbody> <tbody>
{% for project in projects %} {% for project_name in project_names %}
<tr> <tr>
<td>{{ project }}</td> <td><a href="{{ url_for('project_dashboard', project_name = project_name) }}">{{ project_name }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

29
biscd/biscd/templates/project.html

@ -0,0 +1,29 @@
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>{{ project.name }}</h1>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Branch</th>
<th scope="col">Git Repo</th>
<th scope="col">Requirements file</th>
<th scope="col">Tests</th>
<th scope="col">Url</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ project.branch }}</td>
<td>{{ project.git_repo }}</td>
<td>{{ project.requirements_file }}</td>
<td>{{ project.tests }}</td>
<td>{{ project.url }}</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}

6
installation-files/projects_example.yaml

@ -2,14 +2,16 @@ projects:
- The Hunt: - The Hunt:
branch: master branch: master
git_repo: https://git.sciuro.org/Burathar/The-Hunt git_repo: https://git.sciuro.org/Burathar/The-Hunt
requirements-file: requirements.txt requirements_file: requirements.txt
secret: thisissecret secret: thisissecret
tests: tests.py tests: tests.py
url: thehunt url: thehunt
- Foo: - Foo:
branch: master branch: master
git_repo: https://git.sciuro.org/Burathar/The-Hunt git_repo: https://git.sciuro.org/Burathar/The-Hunt
requirements-file: requirements.txt requirements_file: requirements.txt
secret: thisissecret secret: thisissecret
tests: tests.py tests: tests.py
url: bar url: bar
- Test:
branche: master

Loading…
Cancel
Save