Browse Source

Show projects for user

master
Burathar 4 years ago
parent
commit
e2c4151b9e
  1. 13
      biscd/biscd/models/project.py
  2. 2
      biscd/biscd/models/user.py
  3. 6
      biscd/biscd/routes.py
  4. 6
      biscd/biscd/templates/index.html

13
biscd/biscd/models/project.py

@ -22,13 +22,26 @@ class Project(YamlSerializable):
return 'projects' return 'projects'
def __init__(self, name=None, branch='master'): def __init__(self, name=None, branch='master'):
super().__init__()
self.name = name self.name = name
self.branch = branch self.branch = branch
self.relative_production_path = None self.relative_production_path = None
self.git_repo = None self.git_repo = None
def __eq__(self, other):
"""Overrides the default implementation"""
if isinstance(other, Project):
if self.name == other.name:
return True
return False
def __hash__(self):
return hash(self.name)
@property @property
def absulute_path(self): def absulute_path(self):
if not hasattr(self, 'production_path') or not self.relative_production_path:
return None
return Path(config['production_path'].get()) / self.relative_production_path return Path(config['production_path'].get()) / self.relative_production_path
def update(self): def update(self):

2
biscd/biscd/models/user.py

@ -31,7 +31,7 @@ class User(UserMixin, YamlSerializable):
@property @property
def projects(self): def projects(self):
pass #all_projects = Project.get() return set(Project.get(access__owners = self.name) + Project.get(access__public = True))
@projects.setter @projects.setter
def projects(self, projects): def projects(self, projects):

6
biscd/biscd/routes.py

@ -10,10 +10,10 @@ from .froms import NewProjectForm, LoginForm, RegistrationForm, EmptyForm
@app.route('/index', methods=['GET', 'POST']) @app.route('/index', methods=['GET', 'POST'])
def index(): def index():
if current_user.is_authenticated: if current_user.is_authenticated:
project_names = Project.list_names() projects = current_user.projects
else: else:
project_names = None projects = None
return render_template('index.html', project_names=project_names) return render_template('index.html', projects=projects)
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():

6
biscd/biscd/templates/index.html

@ -9,16 +9,16 @@
</div> </div>
</div> </div>
</div> </div>
{% if project_names %} {% if projects %}
<div class="col-lg-12"> <div class="col-lg-12">
<h2 id="typography">Your Projects</h2> <h2 id="typography">Your Projects</h2>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
<tbody> <tbody>
{% for project_name in project_names %} {% for project in projects %}
<tr> <tr>
<td><a href="{{ url_for('project_dashboard', project_name = project_name) }}">{{ project_name }}</a></td> <td><a href="{{ url_for('project_dashboard', project_name = project.name) }}">{{ project.name }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

Loading…
Cancel
Save