Skip to content

Commit

Permalink
Merge pull request #44 from manicmaniac/feedback-assistant-support
Browse files Browse the repository at this point in the history
Add fundamental support for Feedback Assistant
  • Loading branch information
timburks authored Dec 24, 2019
2 parents 1f04011 + 1065c65 commit 4645c4b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Developers and Contributors (please add your name below):
---------------------------------------------------------
Tim Burks (https://github.com/timburks)
Chris Verwymeren (https://github.com/cvee)
Ryosuke Ito (https://github.com/manicmaniac)
2 changes: 1 addition & 1 deletion python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def main():
application = webapp.WSGIApplication([
('/', openradar.web.Index),
('/[0-9]+', openradar.web.RadarViewByPath),
('/(FB)?[0-9]+', openradar.web.RadarViewByPath),
('/api/comment', openradar.api.Comment),
('/api/comment/count', openradar.api.CommentCount),
('/api/comments', openradar.api.Comments),
Expand Down
5 changes: 2 additions & 3 deletions python/openradar/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def get(self):
count = 100
apiresult = memcache.get("apiresult")
if apiresult is None:
radars = db.GqlQuery("select * from Radar order by number_intvalue desc").fetch(count,(page-1)*count)
radars = db.GqlQuery("select * from Radar order by number desc").fetch(count,(page-1)*count)
response = {"result":
[{"id":r.key().id(),
"classification":r.classification,
Expand Down Expand Up @@ -370,7 +370,7 @@ def get(self):
page = 1
apiresult = memcache.get("apiresult")
if apiresult is None:
radars = db.GqlQuery("select * from Radar order by number_intvalue desc").fetch(100,(page-1)*100)
radars = db.GqlQuery("select * from Radar order by number desc").fetch(100,(page-1)*100)
response = {"result":[r.number for r in radars]}
apiresult = simplejson.dumps(response)
self.respondWithText(apiresult)
Expand Down Expand Up @@ -407,7 +407,6 @@ def post(self):
originated = self.request.get("originated")
radar = Radar(title=title,
number=number,
number_intvalue=int(number),
user=user,
status=status,
description=description,
Expand Down
9 changes: 7 additions & 2 deletions python/openradar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class Secret(db.Model):
class Radar(search.SearchableModel):
# This first set of properties are user-specified.
# For flexibility and robustness, we represent them all as strings.
# The Radar Problem ID (we need an int form of this)
# The Radar Problem ID
number = db.StringProperty()
number_intvalue = db.IntegerProperty()

# The radar number this radar duplicates
parent_number = db.StringProperty()
Expand All @@ -40,6 +39,8 @@ class Radar(search.SearchableModel):
# They are automatically set when put() is called.
# We will add more as needed to allow better performance or to simplify
# sorting and querying.
# The integer part of the Radar Problem ID
number_intvalue = db.IntegerProperty()
# when the OpenRadar object was last modified
modified = db.DateTimeProperty()

Expand Down Expand Up @@ -70,6 +71,10 @@ def sanitize(self):
self.description = self.description.strip()
if (self.number):
self.number = self.number.strip()
if self.number.startswith('FB'):
self.number_intvalue = int(self.number[2:])
else:
self.number_intvalue = int(self.number)
if (self.originated):
self.originated = self.originated.strip()
if (self.product):
Expand Down
15 changes: 6 additions & 9 deletions python/openradar/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OldIndex(RequestHandler):
def get(self):
biglist = memcache.get("biglist")
if biglist is None:
radars = db.GqlQuery("select * from Radar order by number_intvalue desc").fetch(100)
radars = db.GqlQuery("select * from Radar order by number desc").fetch(100)
path = os.path.join(os.path.dirname(__file__), os.path.join('../templates', 'biglist.html'))
biglist = template.render(path, {'radars':radars})
memcache.add("biglist", biglist, 3600) # one hour, but we also invalidate on edits and adds
Expand All @@ -52,7 +52,7 @@ def get(self):
pagename = "page" + number
biglist = memcache.get(pagename)
if biglist is None:
radars = db.GqlQuery("select * from Radar order by number_intvalue desc").fetch(PAGESIZE,(int(number)-1)*PAGESIZE)
radars = db.GqlQuery("select * from Radar order by number desc").fetch(PAGESIZE,(int(number)-1)*PAGESIZE)
if len(radars) > 0:
path = os.path.join(os.path.dirname(__file__), os.path.join('../templates', 'biglist.html'))
biglist = template.render(path, {'radars':radars})
Expand Down Expand Up @@ -91,7 +91,6 @@ def post(self):
originated = self.request.get("originated")
radar = Radar(title=title,
number=number,
number_intvalue=int(number),
status=status,
user=user,
description=description,
Expand Down Expand Up @@ -124,9 +123,9 @@ def post(self):
None # let's not worry about downstream problems
self.redirect("/myradars")

RADAR_PATTERN = re.compile("/([0-9]+)")
RADAR_PATTERN = re.compile("/((FB)?[0-9]+)")
class RadarViewByPath(RequestHandler):
def get(self):
def get(self, _prefix):
user = users.GetCurrentUser()
if not user:
page = memcache.get(self.request.path)
Expand Down Expand Up @@ -198,7 +197,6 @@ def post(self):
else:
radar.title = self.request.get("title")
radar.number = self.request.get("number")
radar.number_intvalue = int(self.request.get("number"))
radar.status = self.request.get("status")
radar.description = self.request.get("description")
radar.resolved = self.request.get("resolved")
Expand All @@ -219,7 +217,6 @@ def post(self):
if not radar:
self.respondWithText('Invalid Radar id')
else:
radar.number_intvalue = int(radar.number)
radar.put()
memcache.flush_all()
self.respondWithText('OK')
Expand All @@ -244,7 +241,7 @@ def get(self):
if (not user):
self.respondWithTemplate('please-sign-in.html', {'action': 'view your Radars'})
else:
radars = db.GqlQuery("select * from Radar where user = :1 order by number_intvalue desc", user).fetch(1000)
radars = db.GqlQuery("select * from Radar where user = :1 order by number desc", user).fetch(1000)
self.respondWithTemplate('radar-list.html', {"radars": radars})

class NotFound(RequestHandler):
Expand Down Expand Up @@ -399,7 +396,7 @@ def get(self):
user = users.User(username)
searchlist = ""
if user:
query = db.GqlQuery("select * from Radar where user = :1 order by number_intvalue desc", user)
query = db.GqlQuery("select * from Radar where user = :1 order by number desc", user)
radars = query.fetch(100)
if len(radars) > 0:
path = os.path.join(os.path.dirname(__file__), os.path.join('../templates', 'biglist.html'))
Expand Down
2 changes: 1 addition & 1 deletion python/templates/radar-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Add A New Radar</h1>
<form action="/myradars/add" method=POST>
<div style="float:right"><input type="submit" name="ok"/></div>
<table>
<tr><td>Number:</td><td><input type="text" name="number"/></td>
<tr><td>Number:</td><td><input type="text" name="number" title="/(FB)?[0-9]+/" pattern="(FB)?[0-9]+" required/></td>
<td>Date Originated:</td><td><input type="text" name="originated"/></td></tr>
<tr><td>Status:</td><td><input type="text" name="status"/></td>
<td>Resolved:</td><td><input type="text" name="resolved"/></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion python/templates/radar-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Edit My Radar</h1>
<form action="/myradars/edit?id={{ radar.key.id }}" method=POST>
<div style="float:right"><input type="submit" name="ok"></input></div>
<table>
<tr><td>Number:</td><td><input type="text" name="number" value="{{ radar.number|default_if_none:"" }}"></input></td>
<tr><td>Number:</td><td><input type="text" name="number" value="{{ radar.number|default_if_none:"" }}" title="/(FB)?[0-9]+/" pattern="(FB)?[0-9]+" required></input></td>
<td>Date Originated:</td><td><input type="text" name="originated" value="{{ radar.originated|default_if_none:"" }}"></input></td></tr>
<tr><td>Status:</td><td><input type="text" name="status" value="{{ radar.status|default_if_none:"" }}"></input></td>
<td>Resolved:</td><td><input type="text" name="resolved" value="{{ radar.resolved|default_if_none:"" }}"></input></td></tr>
Expand Down

0 comments on commit 4645c4b

Please sign in to comment.