Exemple #1
0
 def commits_by_path(self, request):
     if not self.project:
         raise api_errors.NotFoundError("project")
     path = request.get_form_var('path', '')
     ref = request.get_form_var('ref') or 'HEAD'
     commits = {'r': 1}
     cs = {}
     try:
         tree = self.project.repo.get_tree(ref, path=path, with_commit=True)
         for v in tree:
             k = v['id']
             v['message_with_emoji'] = parse_emoji(
                 escape(v['commit']['message']))
             author = get_author_by_email(
                 v['commit']['author']['email'])
             if author:
                 v['contributor'] = author
                 v['contributor_url'] = "%s/people/%s" % (DOMAIN, author)
             else:
                 v['contributor'] = v['commit']['author']['name']
             v['age'] = compute_relative_time(v['commit']['author']['time'])
             v['sha'] = v['commit']['sha']
             v['commit_id'] = v['commit']['sha']
             cs[k] = v
         commits['commits'] = cs
     except KeyError:
         commits = {'r': '0', 'err': 'Path not found'}
     except IOError:
         commits = {'r': '0', 'err': 'Path not found'}
     return json.dumps(commits)
Exemple #2
0
 def commits_by_path(self, request):
     if not self.project:
         raise api_errors.NotFoundError("project")
     path = request.get_form_var('path', '')
     ref = request.get_form_var('ref') or 'HEAD'
     commits = {'r': 1}
     cs = {}
     try:
         tree = self.project.repo.get_tree(ref, path=path, with_commit=True)
         for v in tree:
             k = v['id']
             v['message_with_emoji'] = parse_emoji(
                 escape(v['commit']['message']))
             author = get_author_by_email(v['commit']['author']['email'])
             if author:
                 v['contributor'] = author
                 v['contributor_url'] = "%s/people/%s" % (DOMAIN, author)
             else:
                 v['contributor'] = v['commit']['author']['name']
             v['age'] = compute_relative_time(v['commit']['author']['time'])
             v['sha'] = v['commit']['sha']
             v['commit_id'] = v['commit']['sha']
             cs[k] = v
         commits['commits'] = cs
     except KeyError:
         commits = {'r': '0', 'err': 'Path not found'}
     except IOError:
         commits = {'r': '0', 'err': 'Path not found'}
     return json.dumps(commits)
Exemple #3
0
 def edit(self, request):
     if request.method == 'POST':
         title = request.get_form_var('title', '').decode('utf-8')
         content = request.get_form_var('content', '').decode('utf-8')
         user = request.user
         user = user.name if user else None
         if user == self.ticket.author:
             self.ticket.update(title, content)
             content_html = render_markdown_with_project(
                 content, self.proj_name)
             content_html += st('/widgets/markdown_checklist.html',
                                **locals())
             return {'r': 0, 'title': title, 'content': content,
                     'title_html': parse_emoji(title), 'content_html': content_html}
     return {'r': 1}