Commit f83576eb5ced49519e6bb1e8dcb3df3aa9499d6b

Authored by Sergio Oliveira
1 parent e373e29d

Removed open-data api

colab/api/resources.py
... ... @@ -1,120 +0,0 @@
1   -# -*- coding: utf-8 -*-
2   -
3   -from django.contrib.auth import get_user_model
4   -
5   -from tastypie import fields
6   -from tastypie.constants import ALL_WITH_RELATIONS, ALL
7   -from tastypie.resources import ModelResource
8   -
9   -from colab.super_archives.models import Message, EmailAddress
10   -# from proxy.trac.models import Revision, Ticket, Wiki
11   -
12   -User = get_user_model()
13   -
14   -
15   -class UserResource(ModelResource):
16   - class Meta:
17   - queryset = User.objects.filter(is_active=True)
18   - resource_name = 'user'
19   - fields = ['username', 'institution', 'role', 'bio', 'first_name',
20   - 'last_name', 'email']
21   - allowed_methods = ['get', ]
22   - filtering = {
23   - 'email': ('exact', ),
24   - 'username': ALL,
25   - 'institution': ALL,
26   - 'role': ALL,
27   - 'bio': ALL,
28   - }
29   -
30   - def dehydrate_email(self, bundle):
31   - return ''
32   -
33   -
34   -class EmailAddressResource(ModelResource):
35   - user = fields.ForeignKey(UserResource, 'user', full=False, null=True)
36   -
37   - class Meta:
38   - queryset = EmailAddress.objects.all()
39   - resource_name = 'emailaddress'
40   - excludes = ['md5', ]
41   - allowed_methods = ['get', ]
42   - filtering = {
43   - 'address': ('exact', ),
44   - 'user': ALL_WITH_RELATIONS,
45   - 'real_name': ALL,
46   - }
47   -
48   - def dehydrate_address(self, bundle):
49   - return ''
50   -
51   -
52   -class MessageResource(ModelResource):
53   - from_address = fields.ForeignKey(EmailAddressResource, 'from_address',
54   - full=False)
55   -
56   - class Meta:
57   - queryset = Message.objects.all()
58   - resource_name = 'message'
59   - excludes = ['spam', 'subject_clean', 'message_id']
60   - filtering = {
61   - 'from_address': ALL_WITH_RELATIONS,
62   - 'subject': ALL,
63   - 'body': ALL,
64   - 'received_time': ALL,
65   - }
66   -
67   -
68   -# class RevisionResource(ModelResource):
69   -# class Meta:
70   -# queryset = Revision.objects.all()
71   -# resource_name = 'revision'
72   -# excludes = ['collaborators', ]
73   -# filtering = {
74   -# 'key': ALL,
75   -# 'rev': ALL,
76   -# 'author': ALL,
77   -# 'message': ALL,
78   -# 'repository_name': ALL,
79   -# 'created': ALL,
80   -# }
81   -#
82   -#
83   -# class TicketResource(ModelResource):
84   -# class Meta:
85   -# queryset = Ticket.objects.all()
86   -# resource_name = 'ticket'
87   -# excludes = ['collaborators', ]
88   -# filtering = {
89   -# 'id': ALL,
90   -# 'summary': ALL,
91   -# 'description': ALL,
92   -# 'milestone': ALL,
93   -# 'priority': ALL,
94   -# 'component': ALL,
95   -# 'version': ALL,
96   -# 'severity': ALL,
97   -# 'reporter': ALL,
98   -# 'author': ALL,
99   -# 'status': ALL,
100   -# 'keywords': ALL,
101   -# 'created': ALL,
102   -# 'modified': ALL,
103   -# 'modified_by': ALL,
104   -# }
105   -#
106   -#
107   -# class WikiResource(ModelResource):
108   -# class Meta:
109   -# queryset = Wiki.objects.all()
110   -# resource_name = 'wiki'
111   -# excludes = ['collaborators', ]
112   -# filtering = {
113   -# 'name': ALL,
114   -# 'wiki_text': ALL,
115   -# 'author': ALL,
116   -# 'name': ALL,
117   -# 'created': ALL,
118   -# 'modified': ALL,
119   -# 'modified_by': ALL,
120   -# }
colab/api/urls.py
... ... @@ -2,21 +2,9 @@
2 2  
3 3 from django.conf.urls import patterns, include, url
4 4  
5   -from tastypie.api import Api
6   -
7   -from .resources import (UserResource, EmailAddressResource, MessageResource)
8 5 from .views import VoteView
9 6  
10 7  
11   -api = Api(api_name='v1')
12   -api.register(UserResource())
13   -api.register(EmailAddressResource())
14   -api.register(MessageResource())
15   -
16   -
17 8 urlpatterns = patterns('',
18 9 url(r'message/(?P<msg_id>\d+)/vote$', VoteView.as_view()),
19   -
20   - # tastypie urls
21   - url(r'', include(api.urls)),
22 10 )
... ...
colab/static/img/changeset.png

158 Bytes

colab/static/img/opendata3.png

296 Bytes

colab/static/img/thread.png

208 Bytes

colab/static/img/ticket.png

270 Bytes

colab/static/img/wiki.png

202 Bytes

colab/templates/footer.html
... ... @@ -6,7 +6,6 @@
6 6 <p class="col-lg-12 text-center">{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}</p>
7 7 {% endif %}
8 8 <p class="col-lg-12 text-center">
9   - <a href="{% url 'opendata' %}"><img src="{% static 'img/opendata3.png' %}"/></a>
10 9 <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR"><img src="{% static 'img/cc_by_sa.png' %}"/></a>
11 10 </p>
12 11 <p class="col-lg-12 text-center">
... ...
colab/templates/open-data.html
... ... @@ -1,144 +0,0 @@
1   -{% extends "base.html" %}
2   -{% load i18n %}
3   -
4   -{% block main-content %}
5   - <div class="col-lg-12">
6   - <h2>{% trans "OpenData - Communities" %}</h2>
7   - <p>{% trans "If you are interested in any other data that is not provided by this API, please contact us via the ticketing system (you must be registered in order to create a ticket)." %}</p>
8   -
9   - <h3>{% trans "Retrieving data via API" %}</h3>
10   - <p>{% trans "Colab API works through HTTP/REST, always returning JSON objects." %}</p>
11   - <p>
12   - {% trans "The base API URL is" %}:
13   - {% url 'api_v1_top_level' api_name='v1' as BASE_API_URL %}
14   - <a href="{{ BASE_API_URL }}">{{ BASE_API_URL }}</a>
15   - </p>
16   -
17   - <ul class="list-unstyled">
18   - <li>
19   - <p>{% trans "Each model listed below has a resource_uri field available, which is the object's data URI." %}</p>
20   - <p>{% trans "The following list contains the available models to retrieve data and its fields available for filtering" %}:</p>
21   - <ul>
22   - <li>
23   - <strong><a href="{{ BASE_API_URL }}user/">user</a></strong>:
24   - {% trans "Fields" %}: <i>username, email, institution, role, first_name, last_name and bio</i>
25   - <p><strong>{% trans "The email field is not shown for user's privacy, but you can use it to filter" %}</strong></p>
26   - <ul>
27   - <li><i>username</i> - {% trans "The user's username" %}</li>
28   - <li><i>email</i> - {% trans "The user's email address" %}</li>
29   - <li><i>institution</i> - {% trans "What is the user's institution" %}</li>
30   - <li><i>role</i> - {% trans "What is the user's role" %}</li>
31   - <li><i>first_name</i> - {% trans "The user's first name" %}</li>
32   - <li><i>last_name</i> - {% trans "The user's last name" %}</li>
33   - <li><i>bio</i> - {% trans "A mini bio of the user" %}</li>
34   - </ul>
35   - <br />
36   - </li>
37   - <li>
38   - <strong><a href="{{ BASE_API_URL }}emailaddress/">emailaddress</a></strong>:
39   - {% trans "Fields" %}: <i>user, address and real_name</i>
40   - <p><strong>{% trans "The address field is not shown for user's privacy, but you can use it to filter" %}</strong></p>
41   - <ul>
42   - <li><i>user</i> - {% trans "It has a relationshop with the user described above" %}</li>
43   - <li><i>address</i> - {% trans "An email address" %}</li>
44   - <li><i>real_name</i> - {% trans "The user's real name" %}</li>
45   - </ul>
46   - <br />
47   - </li>
48   - <li>
49   - <strong><a href="{{ BASE_API_URL }}message/">message</a></strong>:
50   - {% trans "Fields" %}: <i>from_address, body, id, received_time and subject</i>
51   - <ul>
52   - <li><i>from_address</i> - {% trans "It has a relationship with the emailaddress described above" %}</li>
53   - <li><i>body</i> - {% trans "The message's body" %}</li>
54   - <li><i>subject</i> - {% trans "The message's subject" %}</li>
55   - <li><i>id</i> - {% trans "The message's id" %}</li>
56   - <li><i>received_time</i> - {% trans "The message's received time" %}</li>
57   - </ul>
58   - <br />
59   - </li>
60   - <li>
61   - <strong><a href="{{ BASE_API_URL }}revision/">revision</a></strong>:
62   - {% trans "Fields" %}: <i>author, created, key, message and repository_name</i>
63   - <ul>
64   - <li><i>author</i> - {% trans "The revision's author username" %}</li>
65   - <li><i>created</i> - {% trans "When the revision's were created" %}</li>
66   - <li><i>key</i> - {% trans "The revision's key" %}</li>
67   - <li><i>message</i> - {% trans "The revision's message" %}</li>
68   - <li><i>repository_name</i> - {% trans "The revision's repository name" %}</li>
69   - </ul>
70   - <br />
71   - </li>
72   - <li>
73   - <strong><a href="{{ BASE_API_URL }}ticket/">ticket</a></strong>:
74   - {% trans "Fields" %}: <i>author, component, created, description, id, keywords, milestone, modified, modified_by, priority, reporter, severity, status, summary and version</i>
75   - <ul>
76   - <li><i>author</i> - {% trans "The ticket's author username" %}</li>
77   - <li><i>component</i> - {% trans "The ticket's component" %}</li>
78   - <li><i>created</i> - {% trans "When the ticket's were created" %}</li>
79   - <li><i>description</i> - {% trans "The ticket's description" %}</li>
80   - <li><i>id</i> - {% trans "The ticket's id" %}</li>
81   - <li><i>keywords</i> - {% trans "The ticket's keywords" %}</li>
82   - <li><i>milestone</i> - {% trans "The ticket's milestone" %}</li>
83   - <li><i>modified</i> - {% trans "The time of the last modification" %}</li>
84   - <li><i>modified_by</i> - {% trans "The username of the last user who modified the ticket" %}</li>
85   - <li><i>priority</i> - {% trans "The ticket's priority" %}</li>
86   - <li><i>severity</i> - {% trans "The ticket's severity" %}</li>
87   - <li><i>status</i> - {% trans "The ticket's status" %}</li>
88   - <li><i>summary</i> - {% trans "The ticket's summary" %}</li>
89   - <li><i>version</i> - {% trans "The ticket's version" %}</li>
90   - </ul>
91   - <br />
92   - </li>
93   - <li>
94   - <strong><a href="{{ BASE_API_URL }}wiki/">wiki</a></strong>:
95   - {% trans "Fields" %}: <i>author, created, modified, modified_by, name and wiki_text</i>
96   - <ul>
97   - <li><i>author</i> - {% trans "The wiki's author username" %}</li>
98   - <li><i>created</i> - {% trans "When the wiki's were created" %}</li>
99   - <li><i>modified</i> - {% trans "The time of the last modification" %}</li>
100   - <li><i>modified_by</i> - {% trans "The username of the last user who modified the wiki" %}</li>
101   - <li><i>name</i> - {% trans "The wiki's name" %}</li>
102   - <li><i>wiki_text</i> - {% trans "the wiki's content" %}</li>
103   - </ul>
104   - </li>
105   - </ul>
106   - </li>
107   - </ul>
108   - <ul class="list-unstyled">
109   - <li><h3>{% trans 'Parameters' %}:</h3></li>
110   - <li class="divider"></li>
111   - <li>
112   - <h4><i>limit</i> - {% trans "Results per page" %}</h4>
113   - {% trans "Number of results to be displayed per page." %}
114   - <i>{% trans "Default: 20" %}</i>.
115   - </li>
116   - <li class="divider"></li>
117   - <li>
118   - <h4><i>offset</i> - {% trans "Starts of n element" %}</h4>
119   - {% trans "Where n is the index of the first result to appear in the page." %}
120   - <i>{% trans "Default: 0" %}</i>.
121   - </li>
122   - <li class="divider"><h3>{% trans "Filtering" %}:</h3></li>
123   - <li>
124   - <h4><i>fieldname</i> - {% trans "The field name" %}</h4>
125   - {% trans "If you are looking for a specific wiki, and you know the wiki's name, you can filter it as below" %}
126   - <p><i>...{{ BASE_API_URL }}wiki/?name={% trans "WikiName" %}</i></p>
127   - <p>{% trans "Where &quot;name&quot; is the fieldname and &quot;WikiName&quot; is the value you want to filter." %}</p>
128   - <h4>{% trans "Usage" %}</h4>
129   - <p>{% trans "You can also filter using Django lookup fields with the double underscores, just as below" %}</p>
130   - <p><i>...{{ BASE_API_URL }}wiki/?wiki_text__startswith={% trans "Wiki" %}</i></p>
131   - <p><i>...{{ BASE_API_URL }}ticket/?author__endswith={% trans "test" %}</i></p>
132   - <p><i>...{{ BASE_API_URL }}message/?body__contains={% trans "test" %}</i></p>
133   - <h4>{% trans "Usage with relationships" %}</h4>
134   - <p>{% trans "You can use related fields to filter too. So, you can filter by any field of emailaddress using the 'from_address' field of message, which has a relation to emailaddress. You will achieve the related fields by using double underscore and the field's name. See the example below" %}</p>
135   - <p><i>...{{ BASE_API_URL }}message/?from_address__real_name__contains=Name</i></p>
136   - <p>{% trans "So, real_name is a field of emailaddress, and you had access to this field by a message field called from_address and using double underscore to say you want to use a field of that relationship" %}</p>
137   - <p><strong>{% trans "Note: email filters must be exact. Which means that __contains, __startswith, __endswith and others won't work" %}</strong></p>
138   - <p>{% trans "Another example of usage with relations. Used to retrieve all messages of a given user, using the username or the email field" %}</p>
139   - <p><i>...{{ BASE_API_URL }}message/?from_address__user__username=username</i></p>
140   - <p><i>...{{ BASE_API_URL }}message/?from_address__user__email=usermailexample@host.com</i></p>
141   - </li>
142   - </ul>
143   - </div>
144   -{% endblock %}
colab/urls.py
... ... @@ -8,31 +8,20 @@ from django.views.generic import RedirectView
8 8 admin.autodiscover()
9 9  
10 10 urlpatterns = patterns('',
  11 + url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'),
11 12 url(r'^robots.txt$', 'colab.home.views.robots', name='robots'),
12 13 url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'),
13   - url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'),
14   -
15   - url(r'^open-data/$', TemplateView.as_view(template_name='open-data.html'),
16   - name='opendata'),
17   -
18 14 url(r'^search/', include('colab.search.urls')),
19   - url(r'^archives/', include('colab.super_archives.urls')),
20 15 url(r'^api/', include('colab.api.urls')),
21 16 url(r'^rss/', include('colab.rss.urls')),
22 17  
23   - # Kept for backwards compatibility
24   - url(r'^user/', include('colab.accounts.urls')),
25   - # Kept for backwards compatibility
26   - url(r'^user/', include('colab.accounts.urls')),
27   - # (same here) TODO: move to nginx
28   - url(r'^signup/', include('colab.accounts.urls')),
29 18 url(r'^account/', include('colab.accounts.urls')),
30 19 url(r'^myaccount/(?P<route>.*)$',
31 20 'colab.accounts.views.myaccount_redirect', name='myaccount'),
32 21  
33   - # Uncomment the next line to enable the admin:
34 22 url(r'^colab/admin/', include(admin.site.urls)),
35 23  
  24 + url(r'^archives/', include('colab.super_archives.urls')),
36 25 url(r'^gitlab/', include('colab.plugins.gitlab.urls')),
37 26 url(r'^mezuro/', include('colab.plugins.mezuro.urls')),
38 27 url(r'^social/', include('colab.plugins.noosfero.urls')),
... ...