aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-02-06 22:11:36 +0100
committerGravatar Johannes Christ <[email protected]>2019-02-06 22:11:36 +0100
commit913e2da417b5631944c6dc557961813304ac96d0 (patch)
treec6c3b4dc6cfe85843b66d0018d06f48fcaa71743
parentInitial stab at implementing the nominations API. (diff)
Reimplement nominations on Django.
-rw-r--r--bot/cogs/nominations.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/bot/cogs/nominations.py b/bot/cogs/nominations.py
index 89fd0fba5..93ee0d885 100644
--- a/bot/cogs/nominations.py
+++ b/bot/cogs/nominations.py
@@ -70,17 +70,27 @@ class Nominations(BigBrother):
async def watch_command(self, ctx: Context, user: User, *, reason: str):
"""Talent pool the given `user`."""
- await self.bot.api_client.patch(
- 'bot/nominations',
- json={
- 'active': True,
- 'author': ctx.author.id,
- 'reason': reason,
- 'user': user.id
- }
+ active_nominations = await self.bot.api_client.get(
+ 'bot/nominations/' + str(user.id),
)
- self.watched_users.add(user.id)
- await ctx.send(":ok_hand: user added to talent pool")
+ if active_nominations:
+ active_nominations = await self.bot.api_client.put(
+ 'bot/nominations/' + str(user.id),
+ json={'active': True}
+ )
+ await ctx.send(":ok_hand: user's watch was updated")
+
+ else:
+ active_nominations = await self.bot.api_client.post(
+ 'bot/nominations/' + str(user.id),
+ json={
+ 'active': True,
+ 'author': ctx.author.id,
+ 'reason': reason,
+ }
+ )
+ self.watched_users.add(user.id)
+ await ctx.send(":ok_hand: user added to talent pool")
@bigbrother_group.command(name='unnominate', aliases=('un',))
@with_role(Roles.owner, Roles.admin, Roles.moderator)
@@ -95,7 +105,7 @@ class Nominations(BigBrother):
await ctx.send(":x: the nomination is already inactive")
else:
- await self.bot.api_client.patch(
+ await self.bot.api_client.put(
'bot/nominations/' + str(user.id),
json={'active': False}
)