Repository: fossasia/open-event-server

Issue:
Wrong Information in REST API for FOSSASIA 2017 Summit
API end point : `https://eventyay.com/api/v1/events/6`

 - [x]  Correct the copyright licence from `Attribution` to `Creative Commons Attribution License.`
      Issue : https://github.com/fossasia/open-event-webapp/issues/1063
 - [x]  Correct the Ticket URL from `https://eventyay.com/e/45da88b7/tickets/` to `https://eventyay.com/e/45da88b7/` 
     Issue: https://github.com/fossasia/open-event-webapp/issues/1067
@niranjan94 @SaptakS  Please help regarding this.


Discussion:
@niranjan94 #3239 partially fixes this issue. First part is yet to be solved.
@niranjan94 @poush It seems that the ticket URL is corrected in the PR. I am in doubt why the API end point ` https://eventyay.com/api/v1/events/6` still provides wrong Ticket URL. Please confirm.
Actually the ticket url is stored on the database and last PR fixed the process to store correct url on database. So the url you are receiving is coming directly from database. I think updating the event through wizard will fix this.
@aayusharora this PR has still not be deployed into the eventyay server. The URL will get updated once it is deployed and event get's updated. 

Deployment will be done in a few hours.
I don't know why it is closed. @niranjan94 please check if both the mentioned points are covered.
` Correct the copyright licence from Attribution to Creative Commons Attribution License.
Issue : fossasia/open-event-webapp#1063`
Please recheck this one.
@aayusharora sorry ... the closing was accidental .. Pressed the wrong comment button :sweat_smile: 

@poush Any updates with this. 
@niranjan94 @aayusharora is this issue solved? When I checked the licence is already updated.

in events, api field `licence` will list all details of the license like long_name, logo etc

Resolving patch:
diff --git a/app/api/events.py b/app/api/events.py
--- a/app/api/events.py
+++ b/app/api/events.py
@@ -23,6 +23,7 @@
 from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
     PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
 from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN
+from app.api.helpers.custom_fields import Licence
 
 api = Namespace('events', description='Events')
 
@@ -58,6 +59,7 @@
     'link': fields.String(required=True)
 })
 
+
 SOCIAL_LINK_POST = api.clone('SocialLinkPost', SOCIAL_LINK)
 del SOCIAL_LINK_POST['id']
 
@@ -86,6 +88,7 @@
     'privacy': EventPrivacyField(),
     'ticket_url': fields.Uri(),
     'copyright': fields.Nested(EVENT_COPYRIGHT, allow_null=True),
+    'licence_details': Licence(attribute='copyright.licence', allow_null=True),
     'schedule_published_on': fields.DateTime(),
     'code_of_conduct': fields.String(),
     'social_links': fields.List(fields.Nested(SOCIAL_LINK), attribute='social_link'),
@@ -113,7 +116,7 @@
 del EVENT_POST['id']
 del EVENT_POST['social_links']
 del EVENT_POST['version']
-
+del EVENT_POST['licence_details']
 
 # ###################
 # Data Access Objects
diff --git a/app/api/helpers/custom_fields.py b/app/api/helpers/custom_fields.py
--- a/app/api/helpers/custom_fields.py
+++ b/app/api/helpers/custom_fields.py
@@ -3,6 +3,7 @@
 from datetime import datetime
 from flask import request
 from flask.ext.restplus.fields import Raw, Nested, List
+from app.helpers.data_getter import DataGetter
 
 EMAIL_REGEX = re.compile(r'\S+@\S+\.\S+')
 URI_REGEX = re.compile(r'(http|https|ftp)://\S*(\S+\.|localhost(\:\d+)?/)\S+')
@@ -245,3 +246,20 @@ def validate(self, value):
             self.validation_error = 'Value of %s is not in available choices'
             return False
         return True
+
+
+class Licence(Raw):
+    """
+    Custom field that gets the licence details given the licence name
+    """
+    __schema_example__ = {
+        'name': 'Licence name',
+        'long_name': 'Long licence name',
+        'description': 'Description about the licence',
+        'licence_url': 'http://example.com',
+        'licence_logo': 'http://example.com/example.jpg',
+        'licence_compact_logo': 'http://example.com/example.jpg'
+    }
+
+    def format(self, value):
+        return DataGetter.get_licence_details(value)


Test patch: