community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1864813 - in /comdev/reporter.apache.org/trunk/scripts: rapp/drafts.py wsgi.py
Date Fri, 09 Aug 2019 15:15:00 GMT
Author: humbedooh
Date: Fri Aug  9 15:15:00 2019
New Revision: 1864813

URL: http://svn.apache.org/viewvc?rev=1864813&view=rev
Log:
Add an endpoint for querying reports that have drafts but have not yet been filed.

Modified:
    comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py
    comdev/reporter.apache.org/trunk/scripts/wsgi.py

Modified: comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py?rev=1864813&r1=1864812&r2=1864813&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py Fri Aug  9 15:15:00 2019
@@ -8,6 +8,7 @@ import json
 import re
 import pdata
 import committee_info
+import rapp.whimsy
 
 DRAFTS_DIR = '/tmp/rapp-drafts'
 EDITOR_TYPE = 'unified'
@@ -112,3 +113,44 @@ def save(environ, user):
             'okay': False,
             'error': "Invalid data!",
         }
+
+
+
+def forgotten(environ, user):
+    """ Query for which TLP reports have drafts but haven't filed to agenda yet """
+    agenda, cached = rapp.whimsy.get_whimsy(rapp.whimsy.WHIMSY_AGENDA, environ)
+    drafts = sorted([x for x in os.listdir(DRAFTS_DIR) if x.startswith(EDITOR_TYPE) and x.endswith('.draft')])
+    lost = {}
+    for entry in agenda:
+        ml = entry.get('mail_list') # mailing list id, usually correct
+        rid = entry.get('roster', '').replace('https://whimsy.apache.org/roster/committee/',
'') # ldap id per roster
+        if ml and rid and 'report' in entry and entry.get('attach') >= 'A': # If standard
TLP report entry...
+            
+            if entry.get('report'):
+                lost[rid] = {
+                    'filed': True,
+                    'attach': entry['attach']
+                }
+            else:
+                applicables = []
+                last_report  = ""
+                has_draft = False
+                ts = 0
+                for filename in drafts:
+                    e, p, t, u = filename.split('-', 3)
+                    t = int(t)
+                    if p == rid and t > (time.time() - 45*86400):
+                        applicables.append(filename)
+                if has_access(user, rid) and applicables:
+                    has_draft = True
+                    last_report = open(os.path.join(DRAFTS_DIR, applicables[-1]), "r").read()
+                    ts = os.stat.getmtime(os.path.join(DRAFTS_DIR, applicables[-1]))
+                lost[rid] = {
+                    'filed': False,
+                    'has_draft': has_draft,
+                    'last_draft': last_report,
+                    'draft_timestamp': ts,
+                    'attach': entry['attach']
+                }
+            
+    return { 'report_status': lost }

Modified: comdev/reporter.apache.org/trunk/scripts/wsgi.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/wsgi.py?rev=1864813&r1=1864812&r2=1864813&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/wsgi.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/wsgi.py Fri Aug  9 15:15:00 2019
@@ -20,6 +20,7 @@ webmap = {
     '/api/drafts/save': rapp.drafts.save,
     '/api/drafts/fetch': rapp.drafts.fetch,
     '/api/drafts/delete': rapp.drafts.delete,
+    '/api/drafts/forgotten': rapp.drafts.forgotten,
 }
 
 def app(environ, start_fn):



Mime
View raw message