From 1e1b6dcf38331e264f70ad84690743744b0c3c33 Mon Sep 17 00:00:00 2001
From: Dhriti Shikhar <dhrish20@gmail.com>
Date: Mar 06 2016 15:17:59 +0000
Subject: [PATCH 1/3] Adds a bugzilla widget


---

diff --git a/hubs/defaults.py b/hubs/defaults.py
index 3629062..c37b6cb 100644
--- a/hubs/defaults.py
+++ b/hubs/defaults.py
@@ -73,4 +73,10 @@ def add_user_widgets(session, hub, username, fullname):
             'display_number': 15,
         }))
     hub.widgets.append(widget)
+    widget = hubs.models.Widget(
+        plugin='bugzilla', index=8,
+        _config=json.dumps({
+            'username': username,
+        }))
+    hub.widgets.append(widget)
     return hub
diff --git a/hubs/widgets/__init__.py b/hubs/widgets/__init__.py
index 03084ac..cc7007c 100644
--- a/hubs/widgets/__init__.py
+++ b/hubs/widgets/__init__.py
@@ -14,6 +14,7 @@ from hubs.widgets import pagure_pr
 from hubs.widgets import github_pr
 from hubs.widgets import pagureissues
 from hubs.widgets import githubissues
+from hubs.widgets import bugzilla
 
 from hubs.widgets.workflow import pendingacls
 from hubs.widgets.workflow import updates2stable
@@ -37,6 +38,7 @@ registry = {
     'github_pr': github_pr,
     'pagureissues': pagureissues,
     'githubissues': githubissues,
+    'bugzilla': bugzilla,
 
     'workflow.pendingacls': pendingacls,
     'workflow.updates2stable': updates2stable,
diff --git a/hubs/widgets/bugzilla.py b/hubs/widgets/bugzilla.py
new file mode 100644
index 0000000..bce887d
--- /dev/null
+++ b/hubs/widgets/bugzilla.py
@@ -0,0 +1,76 @@
+import operator
+import requests
+from hubs.hinting import hint, prefixed as _
+from hubs.widgets.base import argument
+import jinja2
+import hubs.validators as validators
+from hubs.widgets.chrome import panel
+import pkgwat.api
+
+chrome = panel("Bugzilla: Issues")
+
+template = jinja2.Template("""
+<ul class="media-list">
+  {% for issue in all_issues[:3] %}
+    <li class="media">
+      <div class="media-left">
+        <a href="https://bugzilla.redhat.com/show_bug.cgi?id={{ issue['id'] }}" target="_blank">
+	  <span class="label label-default">#{{ issue['id'] }}</span>
+	</a>
+      </div>
+      <div class="media-body">
+        <h4 class="media-heading">
+          <a href="https://admin.fedoraproject.org/pkgdb/package/rpms/{{ issue['pkg_name'] }}" target="_blank">{{ issue['pkg_name'] }}</a> -
+          {{ issue['title'] }}
+        </h4>
+      </div>
+    </li>
+  {% endfor %}
+</ul>
+""")
+
+@argument(name="username",
+          default=None,
+          validator=validators.username,
+          help="A FAS username.")
+def data(session, widget, username):
+    username=username
+    pkgdb_url = "https://admin.fedoraproject.org/pkgdb/api/packager/package"
+    url = "/".join([pkgdb_url, username])
+    response = requests.get(url)
+    data = response.json()
+    total_poc = len(data["point of contact"])
+    total_co_main = len(data["co-maintained"])
+    
+    all_issues = list()
+    
+    for package in data["point of contact"]:
+      pkg_details=pkgwat.api.bugs(package['name'])
+      for row in pkg_details['rows']:
+        all_issues.append(
+          dict(
+            pkg_name=package['name'],
+            id=row['id'],
+            title=row['description'],
+          )
+        ) 
+      
+    for package in data["co-maintained"]:
+      pkg_details=pkgwat.api.bugs(package['name'])
+      for row in pkg_details['rows']:
+        all_issues.append(
+          dict(
+            pkg_name=package['name'],
+            id=row['id'],
+            title=row['description'],
+          )
+        )
+
+    return dict(
+      username=username,
+      all_issues=all_issues,
+    )
+
+@hint()
+def should_invalidate(message, session, widget):
+    raise NotImplementedError

From 3bf53a9ffc90b3b8ecc9c2abd2643e2c59cbace4 Mon Sep 17 00:00:00 2001
From: Dhriti Shikhar <dhrish20@gmail.com>
Date: Mar 10 2016 20:01:03 +0000
Subject: [PATCH 2/3] Adds a bugzilla widget: arranges imports and removes unrequired lines


---

diff --git a/hubs/widgets/bugzilla.py b/hubs/widgets/bugzilla.py
index bce887d..73b2c79 100644
--- a/hubs/widgets/bugzilla.py
+++ b/hubs/widgets/bugzilla.py
@@ -1,11 +1,11 @@
-import operator
 import requests
-from hubs.hinting import hint, prefixed as _
-from hubs.widgets.base import argument
 import jinja2
+import pkgwat.api
+
 import hubs.validators as validators
+from hubs.widgets.base import argument
 from hubs.widgets.chrome import panel
-import pkgwat.api
+from hubs.hinting import hint, prefixed as _
 
 chrome = panel("Bugzilla: Issues")
 
@@ -34,37 +34,30 @@ template = jinja2.Template("""
           validator=validators.username,
           help="A FAS username.")
 def data(session, widget, username):
-    username=username
     pkgdb_url = "https://admin.fedoraproject.org/pkgdb/api/packager/package"
     url = "/".join([pkgdb_url, username])
     response = requests.get(url)
     data = response.json()
-    total_poc = len(data["point of contact"])
-    total_co_main = len(data["co-maintained"])
     
-    all_issues = list()
+    all_issues = []
     
     for package in data["point of contact"]:
       pkg_details=pkgwat.api.bugs(package['name'])
       for row in pkg_details['rows']:
-        all_issues.append(
-          dict(
-            pkg_name=package['name'],
-            id=row['id'],
-            title=row['description'],
-          )
-        ) 
+        all_issues=(
+          all_issues+[dict(
+              pkg_name=package['name'],
+              id=row['id'],
+              title=row['description'])])[:3] 
       
     for package in data["co-maintained"]:
       pkg_details=pkgwat.api.bugs(package['name'])
       for row in pkg_details['rows']:
-        all_issues.append(
-          dict(
-            pkg_name=package['name'],
-            id=row['id'],
-            title=row['description'],
-          )
-        )
+          all_issues=(
+            all_issues+[dict(
+              pkg_name=package['name'],
+              id=row['id'],
+              title=row['description'])])[:3]
 
     return dict(
       username=username,

From c37756e4c2d3840b0759bec28c347bbe02d871e7 Mon Sep 17 00:00:00 2001
From: Dhriti Shikhar <dhrish20@gmail.com>
Date: Mar 10 2016 20:47:27 +0000
Subject: [PATCH 3/3] Removes redundent instructions in README.py for fas_credentials.py and credentials.py


---

diff --git a/README.rst b/README.rst
index 3117649..9dac317 100644
--- a/README.rst
+++ b/README.rst
@@ -33,21 +33,6 @@ OK -- with that done, now install the dependencies from PyPI::
 
     $ pip install -r requirements.txt
 
-Give fedora-hubs some FAS credentials.  It's going to need these to query FAS
-for information about other users.  When we deploy this thing to production,
-we'll use a system account for this but for now, just use your personal
-account.  Copy the following into a new file under the fedmsg.d directory
-called fas_credentials.py (``fedmsg.d/fas_credentials.py``) ::
-
-    config = {
-        'fas_credentials': {
-            'username': 'YOUR_FAS_USERNAME_GOES_HERE',
-            'password': 'YOUR_FAS_PASSWORD_GOES_HERE',
-        }
-    }
-
-Make sure to leave the '' around you username and password - don't delete them!
-
 With that, try running the app with::
 
     $ PYTHONPATH=. python populate.py  # To create the db
@@ -84,9 +69,11 @@ Some credentials...
 -------------------
 
 You need to add a new file to the ``fedmsg.d/`` directory.
-Call it ``fedmsg.d/credentials.py``.  It should have some
-secrets in it that you don't want to accidentally share with
-anyone else.. so be sure to keep it private.  It should have
+Call it ``fedmsg.d/credentials.py``. It's needed to query FAS 
+for information about other users. When we deploy this thing to
+production, we'll use a system account for this but for now, just
+use your personal account. You don't want to accidentally share this
+with anyone else. so be sure to keep it private.  It should have
 contents like this::
 
     config = {
@@ -101,8 +88,7 @@ contents like this::
         'github.oauth_token': 'YOUR_GITHUB_TOKEN',
     }
 
-Some widgets will work without the above info being present..
-but it is needed for a subset of them.
+Make sure to leave the '' around you username and password - don't delete them! Some widgets will work without the above information being present but it is needed for a subset of them.
 
 Feed Widget - the Extra Mile
 ----------------------------

