Commit 311b7a13 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

use ndh

parent 8db0989a
......@@ -41,6 +41,7 @@ INSTALLED_APPS = [
'django_tables2',
'django_filters',
'bootstrap3',
'ndh',
'rainboard',
]
......@@ -65,6 +66,7 @@ TEMPLATES = [
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.i18n',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
......
......@@ -2,22 +2,38 @@ from django.utils.safestring import mark_safe
import django_tables2 as tables
from .models import Project, Repo
from . import models
class ProjectTable(tables.Table):
class StrippedTable(tables.Table):
class Meta:
model = Project
fields = ('main_namespace', 'name', 'license', 'homepage')
attrs = {'class': 'table table-striped'}
class ForgeTable(StrippedTable):
class Meta:
model = models.Forge
fields = ('name', 'url')
class NamespaceTable(StrippedTable):
class Meta:
model = models.Namespace
fields = ('group', 'name')
class ProjectTable(StrippedTable):
class Meta:
model = models.Project
fields = ('main_namespace', 'name', 'license', 'homepage')
def render_name(self, record):
return record.get_link()
class RepoTable(tables.Table):
class RepoTable(StrippedTable):
class Meta:
model = Repo
model = models.Repo
fields = ('forge', 'namespace', 'license', 'homepage', 'default_branch', 'open_issues', 'open_pr')
def render_forge(self, value):
......
{% load static bootstrap3 %}<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gepetto Packages</title>
<link rel="stylesheet" href="{% bootstrap_css_url %}" crossorigin="anonymous" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" >
{% extends 'ndh.html' %}
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>body { padding-top: 70px; }</style>
{% block style %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Gepetto Packages</a>
</div>
</div>
</nav>
<div class="container">
{% bootstrap_messages %}
{% block content %}
<h1>Hello, world!</h1>
{% endblock %}
</div>
<hr>
<script src="{% bootstrap_jquery_url %}"></script>
<script src="{% bootstrap_javascript_url %}" crossorigin="anonymous" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" ></script>
<script>{% block scripts %}{% endblock %}</script>
</body>
</html>
{% block pagetitle %}Gepetto Packages{% endblock %}
{% block sitetitle %}Gepetto Packages{% endblock %}
{% block navbarleft %}
<li><a href="{% url 'rainboard:forges' %}">Forges</a></li>
<li><a href="{% url 'rainboard:namespaces' %}">Namespaces</a></li>
{% endblock %}
{% extends 'base.html' %}
{% load django_tables2 %}
{% block content %}
<h1>Forges</h1>
{% render_table table %}
{% endblock %}
{% extends 'base.html' %}
{% load django_tables2 %}
{% block content %}
<h1>Namespaces</h1>
{% render_table table %}
{% endblock %}
......@@ -6,10 +6,8 @@ from .models import Forge, Namespace, Project
app_name = 'rainboard'
urlpatterns = [
# path(r'', views.home, name='home'),
path(r'', views.ProjectsView.as_view(), name='home'),
path(r'forges', ListView.as_view(model=Forge), name='forges'),
path(r'namespaces', ListView.as_view(model=Namespace), name='namespaces'),
path(r'projects', ListView.as_view(model=Project), name='projects'),
path(r'project/<str:slug>', views.ProjectView.as_view(), name='project'),
path('', views.ProjectsView.as_view(), name='home'),
path('forges', views.ForgesView.as_view(), name='forges'),
path('namespaces', views.NamespacesView.as_view(), name='namespaces'),
path('project/<str:slug>', views.ProjectView.as_view(), name='project'),
]
......@@ -3,35 +3,35 @@ from django.views.generic import DetailView
from django_filters.views import FilterView
from django_tables2 import RequestConfig
from django_tables2.views import SingleTableMixin
from django_tables2.views import SingleTableMixin, SingleTableView
from . import models
from . import tables
from .filters import ProjectFilter
from .models import Forge, Namespace, Project
from .tables import ProjectTable, RepoTable
def home(request):
projects = ProjectTable(Project.objects.all())
RequestConfig(request).configure(projects)
return render(request, 'rainboard/home.html', {
'forges': Forge.objects.all(),
'namespaces': Namespace.objects.all(),
'projects': projects,
})
class ForgesView(SingleTableView):
model = models.Forge
table_class = tables.ForgeTable
class NamespacesView(SingleTableView):
model = models.Namespace
table_class = tables.NamespaceTable
class ProjectsView(SingleTableMixin, FilterView):
model = Project
table_class = ProjectTable
model = models.Project
table_class = tables.ProjectTable
filterset_class = ProjectFilter
class ProjectView(DetailView):
model = Project
model = models.Project
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
repos = RepoTable(self.object.repo_set.all())
repos = tables.RepoTable(self.object.repo_set.all())
RequestConfig(self.request).configure(repos)
ctx['repos'] = repos
return ctx
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment