Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed New Project page, Change default project to None #37

Merged
merged 3 commits into from

2 participants

@Jason-Hendry

It seems my previous pull request broke, I've fixed that.
Also when you first install, the index page redirects to projects/contests which fails to load, I've set default to None in settings, also copied the projects list from the admin section for now.

Jason Hendry and others added some commits
@lwc
Owner

Thanks mate, looks good :)

@lwc lwc merged commit 1bb8439 into lwc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2012
  1. Fix 'New Project' and split out edit into seperate method, Allow defa…

    Jason Hendry authored
    …ult project None to point to project list page
  2. Fix 'New Project' and split out edit into seperate method, Allow defa…

    Jason Hendry authored
    …ult project None to point to project list page
  3. Merge branch 'master' of github.com:Jason-Hendry/triage

    Jason Hendry authored
This page is out of date. Refresh to see the latest.
View
10 triage/models/project.py
@@ -19,3 +19,13 @@ def update(project, data):
project[field] = data[field]
return project
+
+ @classmethod
+ def from_data(cls, data):
+ return cls(
+ name=data['name'],
+ token=data['token'],
+ path=data['path'],
+ github=data['github']
+ )
+
View
5 triage/routes.py
@@ -2,6 +2,7 @@ def routes(config):
# Index
config.add_route('index', '/')
# Errors
+ config.add_route('error_projects', '/projects')
config.add_route('error_list', '/projects/{project}')
config.add_route('error_graph', '/projects/{project}/error/{id}/graph')
config.add_route('error_list_changes', '/projects/{project}/changes')
@@ -24,5 +25,7 @@ def routes(config):
config.add_route('admin_user_create', 'admin/users/{user}/create')
config.add_route('admin_user_edit', 'admin/users/{user}/edit')
config.add_route('admin_user_delete', 'admin/users/{user}/delete')
- config.add_route('admin_project_edit', 'admin/projects/{project}')
config.add_route('admin_project', 'admin/projects')
+ config.add_route('admin_project_create', 'admin/projects/{project}/create')
+ config.add_route('admin_project_edit', 'admin/projects/{project}/edit')
+ config.add_route('admin_project_delete', 'admin/projects/{project}/delete')
View
2  triage/settings.py
@@ -4,4 +4,4 @@
'frontend': {'id': 'frontend', 'name': 'Frontend', 'collection': 'frontend-errors'}
}
-DEFAULT_PROJECT = 'contests'
+DEFAULT_PROJECT = None
View
13 triage/templates/admin/projects/create.html
@@ -0,0 +1,13 @@
+{% extends "layout/fluid.html" %}
+
+{% block content %}
+
+<div id="information">
+ <h1><a href="{{route_url('admin_user')}}" title="users">Users</a> / Create new user</h1>
+ {% if form %}
+ {{ form }}
+ {% endif %}
+</div>
+
+{% endblock %}
+
View
13 triage/templates/admin/projects/edit.html
@@ -0,0 +1,13 @@
+{% extends "layout/fluid.html" %}
+
+{% block content %}
+
+<div id="information">
+ <h1><a href="{{route_url('admin_user')}}" title="users">Users</a> / Edit {{user.name}}</h1>
+ {% if form %}
+ {{ form }}
+ {% endif %}
+</div>
+
+{% endblock %}
+
View
2  triage/templates/admin/projects/list.html
@@ -3,7 +3,7 @@
{% block content %}
<div id="information">
- <h2 class="new-project"><a href="">New project</a></h2>
+ <h2 class="new-project"><a href="{{route_url('admin_project_create', project=0)}}">New project</a></h2>
<table class="table projects">
<tbody>
View
23 triage/templates/errors/projects.html
@@ -0,0 +1,23 @@
+{% extends "layout/fluid.html" %}
+
+{% block content %}
+
+<div id="information">
+
+ <table class="table projects">
+ <tbody>
+ {% for project in projects %}
+ <tr>
+ <td><a href="{{route_url('error_list', project=project.token)}}">{{ project.name }}</a></td>
+ <td>{{ project.path }}</td>
+ <td>{{ project.github }}</td>
+ <td class="actions"><a href="{{route_url('admin_project_edit', project=project.token)}}">edit</a></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+</div>
+
+{% endblock %}
+~
+
View
5 triage/views/__init__.py
@@ -8,5 +8,8 @@
@view_config(route_name='index')
def index(request):
selected_project = request.registry.settings['default_project']
- url = request.route_url('error_list', project=selected_project)
+ if not selected_project:
+ url = request.route_url('error_projects')
+ else:
+ url = request.route_url('error_list', project=selected_project)
return HTTPFound(location=url)
View
30 triage/views/admin.py
@@ -108,13 +108,43 @@ def admin_project(request):
'projects': Project.objects()
}
+@view_config(route_name='admin_project_create', permission='authenticated')
+def admin_project_create(request):
+ schema = ProjectFormSchema()
+ form = Form(schema, buttons=('submit',))
+ form_render = None
+
+ if 'submit' in request.POST:
+ controls = request.POST.items()
+ try:
+ values = form.validate(controls)
+ project = Project.from_data(values)
+ project.save()
+
+ return HTTPFound(location=request.route_url('admin_project'))
+
+ except ValidationFailure, e:
+ form_render = e.render()
+
+ if not form_render:
+ form_render = form.render()
+
+ params = {
+ 'form': Markup(form_render)
+ }
+
+ return render_to_response('admin/projects/create.html', params)
+
+
@view_config(route_name='admin_project_edit', permission='authenticated', renderer='admin/projects/edit.html')
def admin_project_edit(request):
def default_values(schema, project):
for field in schema.children:
field.default = project[field.name]
+
project = Project.objects.get(token=request.matchdict['project'])
+
schema = ProjectFormSchema()
default_values(schema, project)
View
7 triage/views/error.py
@@ -73,6 +73,13 @@ def get_errors(request, fetch_recent=False):
return list(pagedErrors)
+@view_config(route_name='error_projects', permission='authenticated', renderer='errors/projects.html')
+def error_projects(request):
+ return {
+ 'projects': Project.objects(),
+ 'basename': path.basename
+ }
+
@view_config(route_name='error_list', permission='authenticated', xhr=True, renderer='errors/list.html')
def error_list(request):
return {
Something went wrong with that request. Please try again.