Skip to content
This repository
Browse code

Many changes

  • Loading branch information...
commit 31d4f136dd4645215bdf700b702fd6ef331827bf 1 parent 2929fc1
Alexei Panov authored April 05, 2012
13  oper.py
@@ -242,6 +242,7 @@ def cancel_package(self, build_id, user, reason):
242 242
         bpkg.pushed = True
243 243
         bpkg.push_user = user
244 244
         bpkg.save()
  245
+        bpkg.remove_old_operations()
245 246
         bpkg.oper_block(user, reason)
246 247
 
247 248
     def cancel_packages(self):
@@ -254,18 +255,14 @@ def _dist_and_ver_from_tag(self, tag):
254 255
         dist = ""
255 256
         ver = ""
256 257
         
257  
-        print("tag: %s" % tag)
258 258
         for prefix in self.dists.keys():
259 259
             begin = tag.find(prefix)
260  
-            print("begin: %s" % begin)
261 260
             if begin >= 0:
262 261
                 dist = self.dists[prefix]
263 262
                 
264 263
                 # version
265 264
                 ver_begin = begin + len(prefix)
266  
-                print("begin+len(prefix): %s" % ver_begin)
267 265
                 ver_part = tag[ver_begin:]
268  
-                print("ver_part: %s" % ver_part)
269 266
                 if 'rawhide' in ver_part:
270 267
                     ver = 'rawhide'
271 268
                 elif 'devel' in ver_part:
@@ -278,7 +275,7 @@ def _dist_and_ver_from_tag(self, tag):
278 275
     def _generate_call_list(self, build, build_repo):
279 276
         dist, ver  = self._dist_and_ver_from_tag(build.tag_name)
280 277
         l = []
281  
-        l.append('/home/pushrepo/bin/koji-pp')
  278
+        l.append('echo')
282 279
         l.append('--id %s' % build.build_id)
283 280
         l.append('--ver %s' % ver)
284 281
         l.append('--repo %s' % build.build_pkg.pkg_repo)
@@ -296,9 +293,6 @@ def push_to_repo(self):
296 293
             if build_repo is None:
297 294
                 print("Warning! Repo is not defined. Skip this build (%s).", build_id)
298 295
                 continue
299  
-            # TODO: make a push process
300  
-            print("Push build id=%s to repo %s" % (build_id, build_repo))
301  
-
302 296
             try:
303 297
                 bpkg = BuildedPackages.objects.get(pk=build_id)
304 298
             except:
@@ -308,15 +302,16 @@ def push_to_repo(self):
308 302
             # cmd to push
309 303
             cmd = self._generate_call_list(bpkg, build_repo)
310 304
             buf = ""
311  
-            #print("Run command:\n\t%s" % str(' ').join(cmd))
312 305
             return_result = subprocess.call(str(' ').join(cmd),shell=True)#, stdout=buf, stderr=buf)
313 306
             all_stdout.append(buf)
314 307
             if return_result != 0:
315 308
                 continue
316 309
             
317 310
             if build_repo.rt_id == 1:
  311
+                bpkg.remove_old_operations()
318 312
                 bpkg.oper_pre_push(user, build_repo)
319 313
             else:
  314
+                bpkg.remove_old_operations()
320 315
                 bpkg.oper_push(user, build_repo)
321 316
 
322 317
         return all_stdout
8  packages/forms.py
@@ -28,12 +28,19 @@ def initial_data(self):
28 28
         bpkg_list = self.get_packages()
29 29
         result = []
30 30
         for bpkg in bpkg_list:
  31
+            selectable = True
  32
+            try:
  33
+                if bpkg.build_pkg.pkg_repo.repo_id == 0:
  34
+                    selectable = False
  35
+            except:
  36
+                selectable = False
31 37
             record = {"selected_package": False,
32 38
                       "package_name": bpkg.full_build_package_name(),
33 39
                       "completion_time": bpkg.completion_time.strftime('%Y-%m-%d %H:%M:%S'),           
34 40
                       "pkg_id": bpkg.build_pkg.pkg_id,
35 41
                       "build_id": bpkg.build_id,
36 42
                       "repo_type": 2,
  43
+                      "selectable": selectable,
37 44
                       }
38 45
             
39 46
             result.append(record)
@@ -86,6 +93,7 @@ class SelectPackagesToPush(forms.Form):
86 93
     pkg_id              = forms.IntegerField(widget=forms.HiddenInput)
87 94
     build_id            = forms.IntegerField(widget=forms.HiddenInput)
88 95
     cancel_reason       = forms.CharField(required=False)
  96
+    selectable          = forms.BooleanField(widget=forms.HiddenInput, required=False)
89 97
     
90 98
 SelectPackagesFormSet = formset_factory(SelectPackagesToPush, extra=0)
91 99
 
12  packages/models.py
@@ -84,13 +84,22 @@ def oper_push(self, user, repo_type):
84 84
         self.push_user          = user
85 85
         self.push_repo_type     = repo_type
86 86
         self.save()
87  
-        bo = BuildOperations(build=self, 
  87
+        bo = BuildOperations(build=self,
88 88
                              operation_time=datetime.datetime.now(),
89 89
                              operation_user=user,
90 90
                              operation_type=2,
91 91
                              operation_description="Finally push to %s" % repo_type.rt_name)
92 92
         bo.save()
93 93
 
  94
+    def remove_old_operations(self):
  95
+        # remove old operations
  96
+        try:
  97
+            list_bo = BuildOperations.objects.filter(build=self)
  98
+        except:
  99
+            print("Oops, operations is not found!")
  100
+
  101
+        list_bo.delete()
  102
+
94 103
 class BuildOperations(models.Model):
95 104
     build                       = models.ForeignKey(BuildedPackages)
96 105
     operation_time              = models.DateTimeField()
@@ -109,3 +118,4 @@ def print_type(self):
109 118
             return "Block"
110 119
 
111 120
         return "Unknown"
  121
+
8  packages/views.py
@@ -51,6 +51,10 @@ def index(request):
51 51
                     push.cancel_packages()
52 52
 
53 53
             return HttpResponseRedirect('/packages/builds/')
  54
+        else:
  55
+            for form in formset:
  56
+                print(form.errors)
  57
+            raise Http404
54 58
     else:
55 59
         ufk = UpdateFromKoji(request.user.username)
56 60
         ufk.update_builds()
@@ -81,7 +85,7 @@ def packages(request):
81 85
 
82 86
 @csrf_protect
83 87
 @login_required(login_url='/accounts/login/')
84  
-def package_edit(request, pkg_id):
  88
+def package_edit(request, pkg_id, redir_page="/packages/"):
85 89
     if request.method == 'POST':
86 90
         form = PackageForm(request.POST)
87 91
         if form.is_valid():
@@ -99,7 +103,7 @@ def package_edit(request, pkg_id):
99 103
 
100 104
             pkg.pkg_repo = repo
101 105
             pkg.save()
102  
-            return HttpResponseRedirect('/packages/')
  106
+            return HttpResponseRedirect(redir_page)
103 107
         else:
104 108
             print(form.errors)
105 109
     try:
4  settings.py
@@ -73,7 +73,7 @@
73 73
     # Put strings here, like "/home/html/static" or "C:/www/django/static".
74 74
     # Always use forward slashes, even on Windows.
75 75
     # Don't forget to use absolute paths, not relative paths.
76  
-    "/home/alex/workspace/code/packageporter/static/",
  76
+    "/Users/alex/workspace/code/packageporter/static/",
77 77
 )
78 78
 
79 79
 # List of finder classes that know how to find static files in
@@ -108,7 +108,7 @@
108 108
     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
109 109
     # Always use forward slashes, even on Windows.
110 110
     # Don't forget to use absolute paths, not relative paths.
111  
-    '/home/alex/workspace/code/packageporter/templates',
  111
+    '/Users/alex/workspace/code/packageporter/templates',
112 112
 )
113 113
 
114 114
 INSTALLED_APPS = (
35  templates/packages/builds_form.html
@@ -22,27 +22,20 @@
22 22
 
23 23
 			  {% for form in formset %}
24 24
 			  <tr>
25  
-				{% for field in form %}
26  
-				{% if field.is_hidden %}
27  
-				  {% if field.label == "Package name" %}
28  
-				    <!-- TODO: this is my test anchor -->
29  
-				    <td>{{ field.value }}</td>
30  
-				  {% else %}
31  
-					  {% if field.label == "Pkg id" %}
32  
-					    <td><a href="http://koji.russianfedora.ru/koji/packageinfo?packageID={{ field.value }}" target="_blank">Package info</a><br>
33  
-					  {% else %}
34  
-						{% if field.label == "Build id" %}
35  
-						  <a href="http://koji.russianfedora.ru/koji/buildinfo?buildID={{ field.value }}" target="_blank">Build info</a></td>
36  
-						{% else %}
37  
-				          <td>{{ field.value }}</td>
38  
-						{% endif %}
39  
-					  {% endif %}
40  
-				  {% endif %}
41  
-					{{ field }}
42  
-				{% else %}
43  
-				<td>{{ field }}</td>
44  
-				{% endif %}
45  
-				{% endfor %}
  25
+                {% if form.selectable.value %}
  26
+                <td>{{ form.selectable }}{{ form.selected_package }}</td>
  27
+                {% else %}
  28
+                <td>{{ form.selectable }}<a href='/packages/package/{{ form.pkg_id.value }}/'>fix</a></td>
  29
+                {% endif %}
  30
+                
  31
+
  32
+                <td>{{ form.package_name.value }}{{ form.package_name }}</td>
  33
+                <td>{{ form.completion_time.value }}{{ form.completion_time }}</td>
  34
+                <td>{{ form.repo_type }}</td>
  35
+                <td><a href="http://koji.russianfedora.ru/koji/packageinfo?packageID={{ form.pkg_id.value }}" target="_blank">Package info</a>{{ form.pkg_id }}
  36
+                <br><a href="http://koji.russianfedora.ru/koji/buildinfo?buildID={{ form.build_id.value }}" target="_blank">Build info</a>{{ form.build_id }}
  37
+                <td>{{ form.cancel_reason }}</td>
  38
+                
46 39
 			  </tr>
47 40
 			  {% endfor %}
48 41
 			</table>

0 notes on commit 31d4f13

Please sign in to comment.
Something went wrong with that request. Please try again.