Adds update ability
authorxray7224 <xray7224@googlemail.com>
Sun, 30 Jun 2013 14:26:49 +0000 (15:26 +0100)
committerxray7224 <jessica@megworld.co.uk>
Thu, 11 Jul 2013 17:21:43 +0000 (18:21 +0100)
mediagoblin/federation/views.py

index f16ae1df0094f2518d2fbdc7701cf58e8fb18d8e..56bacbb199af0fc737df46ac577ca9c0d5679f41 100644 (file)
@@ -56,6 +56,23 @@ def client_register(request):
         if not client:
             return json_response({"error":"Unauthorized.", status=403)
 
+        client.logo_url = data.get("logo_url", client.logo_url)
+        client.application_name = data.get("application_name", client.application_name)
+        app_name = ("application_type", client.application_name)
+        if app_name in client_types:
+            client.application_name = app_name
+        
+        client.save()
+
+        expirey = 0 if client.expirey is None else client.expirey
+
+        return json_response(
+                {
+                    "client_id":client.id,
+                    "client_secret":client.secret,
+                    "expires":expirey,
+                })
+
     elif client_type == "client_associate":
         # registering
         if "client_id" in data:
@@ -78,7 +95,8 @@ def client_register(request):
         expirey=expirey_db,
         application_type=data["type"],
         logo_url=data.get("logo_url", None),
-        redirect_uri=data.get("redirect_uri", None)
+        redirect_uri=data.get("redirect_uri", None),
+        application_type=data["application_type"]
     )
     client.save()