Skip to content
Snippets Groups Projects
Commit f66ff4db authored by Jonathan Seguin's avatar Jonathan Seguin
Browse files

Add project list/create/update

parent 72b71877
No related branches found
No related tags found
1 merge request!2Resolve "Basic command line script to input NGS / Chemo toy data"
......@@ -4,7 +4,7 @@ from django.contrib.auth.models import User
# from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from .models import (Alert, AppSettings, Institution, Lab, Profile)
from .models import (Alert, AppSettings, Institution, Project, Lab, Profile)
class BaseNestedFormSet(forms.BaseFormSet):
......@@ -88,6 +88,12 @@ class InstitutionForm(forms.ModelForm):
fields = ('__all__')
class ProjectForm(forms.ModelForm):
class Meta:
model = Project
fields = ('__all__')
class LabForm(forms.ModelForm):
class Meta:
model = Lab
......
......@@ -42,5 +42,11 @@
<span class="ml-1">{% trans 'Institutions' %}</span>
</a>
</li>
<li class="nav-item {% if active_page == 'projects' %}active{% endif %}">
<a class="nav-link" href="{% url 'admin.projects' %}">
<i class="fas fa-project-diagram fa-fw"></i>
<span class="ml-1">{% trans 'Projects' %}</span>
</a>
</li>
</ul>
{% endblock %}
......@@ -10,6 +10,9 @@ from .views.secure.dashboard import AdminDashboardView, DashboardView
from .views.secure.institution import (InstitutionCreateView,
InstitutionJSONListView,
InstitutionUpdateView, InstitutionView)
from .views.secure.project import (ProjectCreateView,
ProjectJSONListView,
ProjectUpdateView, ProjectView)
from .views.secure.lab import (LabCreateView, LabJSONListView, LabUpdateView,
LabView)
from .views.secure.login_success import LoginSuccess
......@@ -57,6 +60,12 @@ urlpatterns = [
path('secure/admin/institutions/create/', InstitutionCreateView.as_view(), name="admin.institution-create"),
path('secure/admin/institutions/update/<int:pk>', InstitutionUpdateView.as_view(), name="admin.institution-update"),
# Projects
path('secure/admin/projects/', ProjectView.as_view(), name='admin.projects'),
path('secure/admin/projects/list/json/', ProjectJSONListView.as_view(), name='admin.project-json-list'),
path('secure/admin/projects/create/', ProjectCreateView.as_view(), name="admin.project-create"),
path('secure/admin/projects/update/<int:pk>', ProjectUpdateView.as_view(), name="admin.project-update"),
# Alerts
path('secure/admin/comm/alert/', AlertListView.as_view(), name='admin.alert'),
path('secure/admin/comm/alert/create/', AlertCreateView.as_view(), name='admin.alert-create'),
......
from django.template.loader import render_to_string
from django.urls import reverse_lazy
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, TemplateView, UpdateView
from ...forms import ProjectForm
from ...models import Project
from ...views import (ActivePageViewMixin, AjaxDatatableBackboneMixin,
CreateViewMixin, JSONListView, StaffViewMixin,
UpdateViewMixin)
class ProjectView(StaffViewMixin, ActivePageViewMixin, AjaxDatatableBackboneMixin, TemplateView):
page_title = _('Project Management')
active_page = 'Projects'
create_url = reverse_lazy('admin.project-create')
api_url = reverse_lazy('admin.project-json-list')
dt_struct = {
'id': 'all-users',
'headers': [_('Abbreviation'), _('Name'), 'Actions']
}
class ProjectJSONListView(JSONListView):
model = Project
def get_rows(self):
rows = []
for o in self.object_list:
rows.append([
o.abbr,
o.name,
render_to_string(
'portal/templates/portal/widgets/action_buttons.html',
{'buttons': [
(reverse_lazy('admin.project-update', args=[o.id]), 'fas fa-edit', ugettext('Edit'))
]}
)
])
return rows
class ProjectCreateView(StaffViewMixin, CreateViewMixin, CreateView):
model = Project
form_class = ProjectForm
success_url = reverse_lazy('admin.projects')
page_title = _('New Project')
active_page = 'projects'
class ProjectUpdateView(StaffViewMixin, UpdateViewMixin, UpdateView):
model = Project
form_class = ProjectForm
success_url = reverse_lazy('admin.projects')
page_title = _('Update Project')
active_page = 'projects'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment