Skip to content

Commit

Permalink
[frontend][forking] enhance project forking UI
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Mar 3, 2016
1 parent b141323 commit 00948b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/backend/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def handle_fork(self, result):
self.log.info("Forking build {} as {}".format(build_folder, new_build_folder))

result.result = ActionResult.SUCCESS
result.job_ended_on = time.time()
result.ended_on = time.time()

def handle_delete_copr_project(self):
self.log.debug("Action delete copr")
Expand Down
4 changes: 4 additions & 0 deletions frontend/coprs_frontend/coprs/templates/coprs/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

{% block body scoped %}

{% if copr.forked_from and still_forking %}
{{ alert('Forked project is still being prepared for you. It may take a few minutes to duplicate a backend data.', 'warning') }}
{% endif %}

<!-- PROJECT NAME -->
<h1 class="project-name">
{{ copr_title(copr) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h3 class="panel-title"> Regenerate Repositories </h3>
<h3 class="panel-title"> Other Actions </h3>
</div>
<div class="panel-body">
{% if g.user %}
{% if g.user and g.user.id != copr.owner.id %}
<form method="post" action="{{ copr_url('coprs_ns.copr_fork', copr) }}">
<button type="submit" class="button">
<i class="fa fa-code-fork"></i> Fork this project<br />
Expand Down
17 changes: 13 additions & 4 deletions frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ def render_copr_detail(copr):
repos_info[chroot.name_release]["rpm_dl_stat"][chroot.arch] = chroot_rpms_dl_stat
repos_info_list = sorted(repos_info.values(), key=lambda rec: rec["name_release"])
builds = builds_logic.BuildsLogic.get_multiple_by_copr(copr=copr).limit(1).all()

still_forking = actions_logic.ActionsLogic.get_waiting()\
.filter(models.Action.action_type == helpers.ActionTypeEnum("fork"))\
.filter(models.Action.new_value == copr.full_name).all()

return flask.render_template(
"coprs/detail/overview.html",
copr=copr,
Expand All @@ -315,6 +320,7 @@ def render_copr_detail(copr):
repo_dl_stat=repo_dl_stat,
repos_info_list=repos_info_list,
latest_build=builds[0] if len(builds) == 1 else None,
still_forking=still_forking
)


Expand Down Expand Up @@ -812,9 +818,12 @@ def group_copr_build_monitor(copr, detailed=False):
@login_required
@req_with_copr
def copr_fork(copr):
fcopr = ComplexLogic.fork_copr(copr, flask.g.user)
db.session.commit()
fcopr = CoprsLogic.get(flask.g.user.name, copr.name).first()
if not fcopr:
fcopr = ComplexLogic.fork_copr(copr, flask.g.user)
db.session.commit()

flask.flash("Forking project {} for you into {}. Please be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))

flask.flash("Forking project {} for you into {}. Please be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
return render_copr_detail(fcopr)

0 comments on commit 00948b6

Please sign in to comment.