Permalink
Browse files

Many changes

  • Loading branch information...
1 parent 2929fc1 commit 31d4f136dd4645215bdf700b702fd6ef331827bf @elemc committed Apr 5, 2012
Showing with 45 additions and 35 deletions.
  1. +4 −9 oper.py
  2. +8 −0 packages/forms.py
  3. +11 −1 packages/models.py
  4. +6 −2 packages/views.py
  5. +2 −2 settings.py
  6. +14 −21 templates/packages/builds_form.html
View
@@ -242,6 +242,7 @@ def cancel_package(self, build_id, user, reason):
bpkg.pushed = True
bpkg.push_user = user
bpkg.save()
+ bpkg.remove_old_operations()
bpkg.oper_block(user, reason)
def cancel_packages(self):
@@ -254,18 +255,14 @@ def _dist_and_ver_from_tag(self, tag):
dist = ""
ver = ""
- print("tag: %s" % tag)
for prefix in self.dists.keys():
begin = tag.find(prefix)
- print("begin: %s" % begin)
if begin >= 0:
dist = self.dists[prefix]
# version
ver_begin = begin + len(prefix)
- print("begin+len(prefix): %s" % ver_begin)
ver_part = tag[ver_begin:]
- print("ver_part: %s" % ver_part)
if 'rawhide' in ver_part:
ver = 'rawhide'
elif 'devel' in ver_part:
@@ -278,7 +275,7 @@ def _dist_and_ver_from_tag(self, tag):
def _generate_call_list(self, build, build_repo):
dist, ver = self._dist_and_ver_from_tag(build.tag_name)
l = []
- l.append('/home/pushrepo/bin/koji-pp')
+ l.append('echo')
l.append('--id %s' % build.build_id)
l.append('--ver %s' % ver)
l.append('--repo %s' % build.build_pkg.pkg_repo)
@@ -296,9 +293,6 @@ def push_to_repo(self):
if build_repo is None:
print("Warning! Repo is not defined. Skip this build (%s).", build_id)
continue
- # TODO: make a push process
- print("Push build id=%s to repo %s" % (build_id, build_repo))
-
try:
bpkg = BuildedPackages.objects.get(pk=build_id)
except:
@@ -308,15 +302,16 @@ def push_to_repo(self):
# cmd to push
cmd = self._generate_call_list(bpkg, build_repo)
buf = ""
- #print("Run command:\n\t%s" % str(' ').join(cmd))
return_result = subprocess.call(str(' ').join(cmd),shell=True)#, stdout=buf, stderr=buf)
all_stdout.append(buf)
if return_result != 0:
continue
if build_repo.rt_id == 1:
+ bpkg.remove_old_operations()
bpkg.oper_pre_push(user, build_repo)
else:
+ bpkg.remove_old_operations()
bpkg.oper_push(user, build_repo)
return all_stdout
View
@@ -28,12 +28,19 @@ def initial_data(self):
bpkg_list = self.get_packages()
result = []
for bpkg in bpkg_list:
+ selectable = True
+ try:
+ if bpkg.build_pkg.pkg_repo.repo_id == 0:
+ selectable = False
+ except:
+ selectable = False
record = {"selected_package": False,
"package_name": bpkg.full_build_package_name(),
"completion_time": bpkg.completion_time.strftime('%Y-%m-%d %H:%M:%S'),
"pkg_id": bpkg.build_pkg.pkg_id,
"build_id": bpkg.build_id,
"repo_type": 2,
+ "selectable": selectable,
}
result.append(record)
@@ -86,6 +93,7 @@ class SelectPackagesToPush(forms.Form):
pkg_id = forms.IntegerField(widget=forms.HiddenInput)
build_id = forms.IntegerField(widget=forms.HiddenInput)
cancel_reason = forms.CharField(required=False)
+ selectable = forms.BooleanField(widget=forms.HiddenInput, required=False)
SelectPackagesFormSet = formset_factory(SelectPackagesToPush, extra=0)
View
@@ -84,13 +84,22 @@ def oper_push(self, user, repo_type):
self.push_user = user
self.push_repo_type = repo_type
self.save()
- bo = BuildOperations(build=self,
+ bo = BuildOperations(build=self,
operation_time=datetime.datetime.now(),
operation_user=user,
operation_type=2,
operation_description="Finally push to %s" % repo_type.rt_name)
bo.save()
+ def remove_old_operations(self):
+ # remove old operations
+ try:
+ list_bo = BuildOperations.objects.filter(build=self)
+ except:
+ print("Oops, operations is not found!")
+
+ list_bo.delete()
+
class BuildOperations(models.Model):
build = models.ForeignKey(BuildedPackages)
operation_time = models.DateTimeField()
@@ -109,3 +118,4 @@ def print_type(self):
return "Block"
return "Unknown"
+
View
@@ -51,6 +51,10 @@ def index(request):
push.cancel_packages()
return HttpResponseRedirect('/packages/builds/')
+ else:
+ for form in formset:
+ print(form.errors)
+ raise Http404
else:
ufk = UpdateFromKoji(request.user.username)
ufk.update_builds()
@@ -81,7 +85,7 @@ def packages(request):
@csrf_protect
@login_required(login_url='/accounts/login/')
-def package_edit(request, pkg_id):
+def package_edit(request, pkg_id, redir_page="/packages/"):
if request.method == 'POST':
form = PackageForm(request.POST)
if form.is_valid():
@@ -99,7 +103,7 @@ def package_edit(request, pkg_id):
pkg.pkg_repo = repo
pkg.save()
- return HttpResponseRedirect('/packages/')
+ return HttpResponseRedirect(redir_page)
else:
print(form.errors)
try:
View
@@ -73,7 +73,7 @@
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- "/home/alex/workspace/code/packageporter/static/",
+ "/Users/alex/workspace/code/packageporter/static/",
)
# List of finder classes that know how to find static files in
@@ -108,7 +108,7 @@
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- '/home/alex/workspace/code/packageporter/templates',
+ '/Users/alex/workspace/code/packageporter/templates',
)
INSTALLED_APPS = (
@@ -22,27 +22,20 @@
{% for form in formset %}
<tr>
- {% for field in form %}
- {% if field.is_hidden %}
- {% if field.label == "Package name" %}
- <!-- TODO: this is my test anchor -->
- <td>{{ field.value }}</td>
- {% else %}
- {% if field.label == "Pkg id" %}
- <td><a href="http://koji.russianfedora.ru/koji/packageinfo?packageID={{ field.value }}" target="_blank">Package info</a><br>
- {% else %}
- {% if field.label == "Build id" %}
- <a href="http://koji.russianfedora.ru/koji/buildinfo?buildID={{ field.value }}" target="_blank">Build info</a></td>
- {% else %}
- <td>{{ field.value }}</td>
- {% endif %}
- {% endif %}
- {% endif %}
- {{ field }}
- {% else %}
- <td>{{ field }}</td>
- {% endif %}
- {% endfor %}
+ {% if form.selectable.value %}
+ <td>{{ form.selectable }}{{ form.selected_package }}</td>
+ {% else %}
+ <td>{{ form.selectable }}<a href='/packages/package/{{ form.pkg_id.value }}/'>fix</a></td>
+ {% endif %}
+
+
+ <td>{{ form.package_name.value }}{{ form.package_name }}</td>
+ <td>{{ form.completion_time.value }}{{ form.completion_time }}</td>
+ <td>{{ form.repo_type }}</td>
+ <td><a href="http://koji.russianfedora.ru/koji/packageinfo?packageID={{ form.pkg_id.value }}" target="_blank">Package info</a>{{ form.pkg_id }}
+ <br><a href="http://koji.russianfedora.ru/koji/buildinfo?buildID={{ form.build_id.value }}" target="_blank">Build info</a>{{ form.build_id }}
+ <td>{{ form.cancel_reason }}</td>
+
</tr>
{% endfor %}
</table>

0 comments on commit 31d4f13

Please sign in to comment.