Fix bugs, mostly related to date formatting.
This commit is contained in:
parent
ddf5f2053c
commit
3542a520f5
11 changed files with 42 additions and 40 deletions
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import json
|
||||
|
||||
from flask import Blueprint, request, make_response
|
||||
from flask import Blueprint, request
|
||||
from flask.ext.restful import Resource, abort, Api, reqparse
|
||||
from flask.ext.restful.utils.cors import crossdomain
|
||||
from calendar import timegm
|
||||
|
|
|
@ -7,8 +7,9 @@ from flask.ext.restful import abort
|
|||
from app import app
|
||||
from endpoints.api import (RepositoryParamResource, parse_args, query_param, nickname, resource,
|
||||
require_repo_read, require_repo_write, validate_json_request,
|
||||
ApiResource, internal_only)
|
||||
ApiResource, internal_only, format_date)
|
||||
from endpoints.common import start_build
|
||||
from endpoints.trigger import BuildTrigger
|
||||
from data import model
|
||||
from auth.permissions import ModifyRepositoryPermission
|
||||
|
||||
|
@ -18,14 +19,28 @@ user_files = app.config['USERFILES']
|
|||
build_logs = app.config['BUILDLOGS']
|
||||
|
||||
|
||||
def trigger_view(trigger):
|
||||
if trigger and trigger.uuid:
|
||||
config_dict = json.loads(trigger.config)
|
||||
build_trigger = BuildTrigger.get_trigger_for_service(trigger.service.name)
|
||||
return {
|
||||
'service': trigger.service.name,
|
||||
'config': config_dict,
|
||||
'id': trigger.uuid,
|
||||
'connected_user': trigger.connected_user.username,
|
||||
'is_active': build_trigger.is_active(config_dict)
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def build_status_view(build_obj, can_write=False):
|
||||
status = build_logs.get_status(build_obj.uuid)
|
||||
logger.debug('Can write: %s job_config: %s', can_write, build_obj.job_config)
|
||||
build_obj.job_config = None
|
||||
resp = {
|
||||
'id': build_obj.uuid,
|
||||
'phase': build_obj.phase,
|
||||
'started': build_obj.started,
|
||||
'started': format_date(build_obj.started),
|
||||
'display_name': build_obj.display_name,
|
||||
'status': status,
|
||||
'job_config': json.loads(build_obj.job_config) if can_write else None,
|
||||
|
@ -33,8 +48,9 @@ def build_status_view(build_obj, can_write=False):
|
|||
'trigger': trigger_view(build_obj.trigger),
|
||||
'resource_key': build_obj.resource_key,
|
||||
}
|
||||
|
||||
if can_write:
|
||||
resp['archive_url'] = user_files.get_file_url(build.resource_key)
|
||||
resp['archive_url'] = user_files.get_file_url(build_obj.resource_key)
|
||||
|
||||
return resp
|
||||
|
||||
|
@ -63,9 +79,9 @@ class RepositoryBuildList(RepositoryParamResource):
|
|||
},
|
||||
}
|
||||
|
||||
@require_repo_read
|
||||
@parse_args
|
||||
@query_param('limit', 'The maximum number of builds to return', type=int, default=5)
|
||||
@require_repo_read
|
||||
@nickname('getRepoBuilds')
|
||||
def get(self, args, namespace, repository):
|
||||
""" Get the list of repository builds. """
|
||||
|
|
|
@ -4,7 +4,8 @@ from collections import defaultdict
|
|||
from flask.ext.restful import abort
|
||||
|
||||
from app import app
|
||||
from endpoints.api import resource, nickname, require_repo_read, RepositoryParamResource
|
||||
from endpoints.api import (resource, nickname, require_repo_read, RepositoryParamResource,
|
||||
format_date)
|
||||
from data import model
|
||||
from util.cache import cache_control_flask_restful
|
||||
|
||||
|
@ -20,7 +21,7 @@ def image_view(image):
|
|||
command = extended_props.command
|
||||
return {
|
||||
'id': image.docker_image_id,
|
||||
'created': extended_props.created,
|
||||
'created': format_date(extended_props.created),
|
||||
'comment': extended_props.comment,
|
||||
'command': json.loads(command) if command else None,
|
||||
'ancestors': image.ancestors,
|
||||
|
|
|
@ -4,7 +4,8 @@ from datetime import datetime, timedelta
|
|||
from flask.ext.restful import abort
|
||||
|
||||
from endpoints.api import (resource, nickname, ApiResource, query_param, parse_args,
|
||||
RepositoryParamResource, require_repo_admin, related_user_resource)
|
||||
RepositoryParamResource, require_repo_admin, related_user_resource,
|
||||
format_date)
|
||||
from auth.permissions import AdministerOrganizationPermission, AdministerOrganizationPermission
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from data import model
|
||||
|
@ -15,7 +16,7 @@ def log_view(log):
|
|||
'kind': log.kind.name,
|
||||
'metadata': json.loads(log.metadata_json),
|
||||
'ip': log.ip,
|
||||
'datetime': log.datetime,
|
||||
'datetime': format_date(log.datetime),
|
||||
}
|
||||
|
||||
if log.performer:
|
||||
|
@ -56,8 +57,8 @@ def get_logs(namespace, start_time, end_time, performer_name=None,
|
|||
logs = model.list_logs(namespace, start_time, end_time, performer=performer,
|
||||
repository=repository)
|
||||
return {
|
||||
'start_time': start_time,
|
||||
'end_time': end_time,
|
||||
'start_time': format_date(start_time),
|
||||
'end_time': format_date(end_time),
|
||||
'logs': [log_view(log) for log in logs]
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ class RepositoryUserPermission(RepositoryParamResource):
|
|||
|
||||
@require_repo_admin
|
||||
@nickname('deleteUserPermissions')
|
||||
def delete(namespace, repository, username):
|
||||
def delete(self, namespace, repository, username):
|
||||
""" Delete the permission for the user. """
|
||||
try:
|
||||
model.delete_user_permission(username, namespace, repository)
|
||||
|
|
|
@ -156,10 +156,8 @@ class PermissionPrototypeList(ApiResource):
|
|||
delegate_username = delegate_name if delegate_kind == 'user' else None
|
||||
delegate_teamname = delegate_name if delegate_kind == 'team' else None
|
||||
|
||||
activating_user = (model.get_user(activating_username)
|
||||
if activating_username else None)
|
||||
delegate_user = (model.get_user(delegate_username)
|
||||
if delegate_username else None)
|
||||
activating_user = (model.get_user(activating_username) if activating_username else None)
|
||||
delegate_user = (model.get_user(delegate_username) if delegate_username else None)
|
||||
delegate_team = (model.get_organization_team(orgname, delegate_teamname)
|
||||
if delegate_teamname else None)
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ class OrganizationTeam(ApiResource):
|
|||
'description': 'Description of a team',
|
||||
'required': [
|
||||
'role',
|
||||
'description',
|
||||
],
|
||||
'properties': {
|
||||
'role': {
|
||||
|
|
|
@ -10,7 +10,7 @@ from app import app
|
|||
from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin,
|
||||
log_action, request_error, query_param, parse_args,
|
||||
validate_json_request)
|
||||
from endpoints.api.build import build_status_view
|
||||
from endpoints.api.build import build_status_view, trigger_view
|
||||
from endpoints.common import start_build
|
||||
from endpoints.trigger import (BuildTrigger, TriggerDeactivationException,
|
||||
TriggerActivationException, EmptyRepositoryException)
|
||||
|
@ -21,21 +21,6 @@ from auth.permissions import UserPermission
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def trigger_view(trigger):
|
||||
if trigger and trigger.uuid:
|
||||
config_dict = json.loads(trigger.config)
|
||||
build_trigger = BuildTrigger.get_trigger_for_service(trigger.service.name)
|
||||
return {
|
||||
'service': trigger.service.name,
|
||||
'config': config_dict,
|
||||
'id': trigger.uuid,
|
||||
'connected_user': trigger.connected_user.username,
|
||||
'is_active': build_trigger.is_active(config_dict)
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def _prepare_webhook_url(scheme, username, password, hostname, path):
|
||||
auth_hostname = '%s:%s@%s' % (quote(username), quote(password), hostname)
|
||||
return urlunparse((scheme, auth_hostname, path, '', '', ''))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
from flask import request, url_for
|
||||
from flask.ext.restful import abort
|
||||
|
||||
|
@ -74,4 +76,4 @@ class Webhook(RepositoryParamResource):
|
|||
log_action('delete_repo_webhook', namespace,
|
||||
{'repo': repository, 'webhook_id': public_id},
|
||||
repo=model.get_repository(namespace, repository))
|
||||
return make_response('No Content', 204)
|
||||
return 'No Content', 204
|
||||
|
|
|
@ -1450,7 +1450,7 @@ function LogUsageChart(titleMap) {
|
|||
* Builds the D3-representation of the data.
|
||||
*/
|
||||
LogUsageChart.prototype.buildData_ = function(logs) {
|
||||
var parseDate = d3.time.format("%a, %d %b %Y %H:%M:%S GMT").parse
|
||||
var parseDate = d3.time.format("%a, %d %b %Y %H:%M:%S %Z").parse
|
||||
|
||||
// Build entries for each kind of event that occurred, on each day. We have one
|
||||
// entry per {kind, day} pair.
|
||||
|
|
|
@ -117,12 +117,12 @@ var isProd = document.location.hostname === 'quay.io';
|
|||
<div class="col-md-8">
|
||||
<ul>
|
||||
<li><span class="copyright">©2014 DevTable, LLC</span></li>
|
||||
<li><a href="http://blog.devtable.com/">Blog</a></li>
|
||||
<li><a href="http://blog.devtable.com/" target="_blank">Blog</a></li>
|
||||
<li><a href="/tos" target="_self">Terms</a></li>
|
||||
<li><a href="/privacy" target="_self">Privacy</a></li>
|
||||
<li><a href="/security/">Security</a></li>
|
||||
<li><a href="/about/">About</a></li>
|
||||
<li><b><a href="/contact/">Contact</a></b></li>
|
||||
<li><a href="/security/" target="_self">Security</a></li>
|
||||
<li><a href="/about/" target="_self">About</a></li>
|
||||
<li><b><a href="/contact/" target="_self">Contact</a></b></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
Reference in a new issue