From f83576eb5ced49519e6bb1e8dcb3df3aa9499d6b Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Tue, 28 Jul 2015 15:15:38 -0300 Subject: [PATCH] Removed open-data api --- colab/api/resources.py | 120 ------------------------------------------------------------------------------------------------------------------------ colab/api/urls.py | 12 ------------ colab/static/img/changeset.png | Bin 158 -> 0 bytes colab/static/img/opendata3.png | Bin 296 -> 0 bytes colab/static/img/thread.png | Bin 208 -> 0 bytes colab/static/img/ticket.png | Bin 270 -> 0 bytes colab/static/img/wiki.png | Bin 202 -> 0 bytes colab/templates/footer.html | 1 - colab/templates/open-data.html | 144 ------------------------------------------------------------------------------------------------------------------------------------------------ colab/urls.py | 15 ++------------- 10 files changed, 2 insertions(+), 290 deletions(-) delete mode 100644 colab/api/resources.py delete mode 100644 colab/static/img/changeset.png delete mode 100644 colab/static/img/opendata3.png delete mode 100644 colab/static/img/thread.png delete mode 100644 colab/static/img/ticket.png delete mode 100644 colab/static/img/wiki.png delete mode 100644 colab/templates/open-data.html diff --git a/colab/api/resources.py b/colab/api/resources.py deleted file mode 100644 index 38baa71..0000000 --- a/colab/api/resources.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- - -from django.contrib.auth import get_user_model - -from tastypie import fields -from tastypie.constants import ALL_WITH_RELATIONS, ALL -from tastypie.resources import ModelResource - -from colab.super_archives.models import Message, EmailAddress -# from proxy.trac.models import Revision, Ticket, Wiki - -User = get_user_model() - - -class UserResource(ModelResource): - class Meta: - queryset = User.objects.filter(is_active=True) - resource_name = 'user' - fields = ['username', 'institution', 'role', 'bio', 'first_name', - 'last_name', 'email'] - allowed_methods = ['get', ] - filtering = { - 'email': ('exact', ), - 'username': ALL, - 'institution': ALL, - 'role': ALL, - 'bio': ALL, - } - - def dehydrate_email(self, bundle): - return '' - - -class EmailAddressResource(ModelResource): - user = fields.ForeignKey(UserResource, 'user', full=False, null=True) - - class Meta: - queryset = EmailAddress.objects.all() - resource_name = 'emailaddress' - excludes = ['md5', ] - allowed_methods = ['get', ] - filtering = { - 'address': ('exact', ), - 'user': ALL_WITH_RELATIONS, - 'real_name': ALL, - } - - def dehydrate_address(self, bundle): - return '' - - -class MessageResource(ModelResource): - from_address = fields.ForeignKey(EmailAddressResource, 'from_address', - full=False) - - class Meta: - queryset = Message.objects.all() - resource_name = 'message' - excludes = ['spam', 'subject_clean', 'message_id'] - filtering = { - 'from_address': ALL_WITH_RELATIONS, - 'subject': ALL, - 'body': ALL, - 'received_time': ALL, - } - - -# class RevisionResource(ModelResource): -# class Meta: -# queryset = Revision.objects.all() -# resource_name = 'revision' -# excludes = ['collaborators', ] -# filtering = { -# 'key': ALL, -# 'rev': ALL, -# 'author': ALL, -# 'message': ALL, -# 'repository_name': ALL, -# 'created': ALL, -# } -# -# -# class TicketResource(ModelResource): -# class Meta: -# queryset = Ticket.objects.all() -# resource_name = 'ticket' -# excludes = ['collaborators', ] -# filtering = { -# 'id': ALL, -# 'summary': ALL, -# 'description': ALL, -# 'milestone': ALL, -# 'priority': ALL, -# 'component': ALL, -# 'version': ALL, -# 'severity': ALL, -# 'reporter': ALL, -# 'author': ALL, -# 'status': ALL, -# 'keywords': ALL, -# 'created': ALL, -# 'modified': ALL, -# 'modified_by': ALL, -# } -# -# -# class WikiResource(ModelResource): -# class Meta: -# queryset = Wiki.objects.all() -# resource_name = 'wiki' -# excludes = ['collaborators', ] -# filtering = { -# 'name': ALL, -# 'wiki_text': ALL, -# 'author': ALL, -# 'name': ALL, -# 'created': ALL, -# 'modified': ALL, -# 'modified_by': ALL, -# } diff --git a/colab/api/urls.py b/colab/api/urls.py index 4e0b29c..9f198f4 100644 --- a/colab/api/urls.py +++ b/colab/api/urls.py @@ -2,21 +2,9 @@ from django.conf.urls import patterns, include, url -from tastypie.api import Api - -from .resources import (UserResource, EmailAddressResource, MessageResource) from .views import VoteView -api = Api(api_name='v1') -api.register(UserResource()) -api.register(EmailAddressResource()) -api.register(MessageResource()) - - urlpatterns = patterns('', url(r'message/(?P\d+)/vote$', VoteView.as_view()), - - # tastypie urls - url(r'', include(api.urls)), ) diff --git a/colab/static/img/changeset.png b/colab/static/img/changeset.png deleted file mode 100644 index 80e3ee1..0000000 Binary files a/colab/static/img/changeset.png and /dev/null differ diff --git a/colab/static/img/opendata3.png b/colab/static/img/opendata3.png deleted file mode 100644 index dc12759..0000000 Binary files a/colab/static/img/opendata3.png and /dev/null differ diff --git a/colab/static/img/thread.png b/colab/static/img/thread.png deleted file mode 100644 index c429cbe..0000000 Binary files a/colab/static/img/thread.png and /dev/null differ diff --git a/colab/static/img/ticket.png b/colab/static/img/ticket.png deleted file mode 100644 index 09fcc0c..0000000 Binary files a/colab/static/img/ticket.png and /dev/null differ diff --git a/colab/static/img/wiki.png b/colab/static/img/wiki.png deleted file mode 100644 index c267a33..0000000 Binary files a/colab/static/img/wiki.png and /dev/null differ diff --git a/colab/templates/footer.html b/colab/templates/footer.html index 197c296..c961974 100644 --- a/colab/templates/footer.html +++ b/colab/templates/footer.html @@ -6,7 +6,6 @@

{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}

{% endif %}

-

diff --git a/colab/templates/open-data.html b/colab/templates/open-data.html deleted file mode 100644 index 17d5d74..0000000 --- a/colab/templates/open-data.html +++ /dev/null @@ -1,144 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block main-content %} -

-

{% trans "OpenData - Communities" %}

-

{% 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)." %}

- -

{% trans "Retrieving data via API" %}

-

{% trans "Colab API works through HTTP/REST, always returning JSON objects." %}

-

- {% trans "The base API URL is" %}: - {% url 'api_v1_top_level' api_name='v1' as BASE_API_URL %} - {{ BASE_API_URL }} -

- -
    -
  • -

    {% trans "Each model listed below has a resource_uri field available, which is the object's data URI." %}

    -

    {% trans "The following list contains the available models to retrieve data and its fields available for filtering" %}:

    -
      -
    • - user: - {% trans "Fields" %}: username, email, institution, role, first_name, last_name and bio -

      {% trans "The email field is not shown for user's privacy, but you can use it to filter" %}

      -
        -
      • username - {% trans "The user's username" %}
      • -
      • email - {% trans "The user's email address" %}
      • -
      • institution - {% trans "What is the user's institution" %}
      • -
      • role - {% trans "What is the user's role" %}
      • -
      • first_name - {% trans "The user's first name" %}
      • -
      • last_name - {% trans "The user's last name" %}
      • -
      • bio - {% trans "A mini bio of the user" %}
      • -
      -
      -
    • -
    • - emailaddress: - {% trans "Fields" %}: user, address and real_name -

      {% trans "The address field is not shown for user's privacy, but you can use it to filter" %}

      -
        -
      • user - {% trans "It has a relationshop with the user described above" %}
      • -
      • address - {% trans "An email address" %}
      • -
      • real_name - {% trans "The user's real name" %}
      • -
      -
      -
    • -
    • - message: - {% trans "Fields" %}: from_address, body, id, received_time and subject -
        -
      • from_address - {% trans "It has a relationship with the emailaddress described above" %}
      • -
      • body - {% trans "The message's body" %}
      • -
      • subject - {% trans "The message's subject" %}
      • -
      • id - {% trans "The message's id" %}
      • -
      • received_time - {% trans "The message's received time" %}
      • -
      -
      -
    • -
    • - revision: - {% trans "Fields" %}: author, created, key, message and repository_name -
        -
      • author - {% trans "The revision's author username" %}
      • -
      • created - {% trans "When the revision's were created" %}
      • -
      • key - {% trans "The revision's key" %}
      • -
      • message - {% trans "The revision's message" %}
      • -
      • repository_name - {% trans "The revision's repository name" %}
      • -
      -
      -
    • -
    • - ticket: - {% trans "Fields" %}: author, component, created, description, id, keywords, milestone, modified, modified_by, priority, reporter, severity, status, summary and version -
        -
      • author - {% trans "The ticket's author username" %}
      • -
      • component - {% trans "The ticket's component" %}
      • -
      • created - {% trans "When the ticket's were created" %}
      • -
      • description - {% trans "The ticket's description" %}
      • -
      • id - {% trans "The ticket's id" %}
      • -
      • keywords - {% trans "The ticket's keywords" %}
      • -
      • milestone - {% trans "The ticket's milestone" %}
      • -
      • modified - {% trans "The time of the last modification" %}
      • -
      • modified_by - {% trans "The username of the last user who modified the ticket" %}
      • -
      • priority - {% trans "The ticket's priority" %}
      • -
      • severity - {% trans "The ticket's severity" %}
      • -
      • status - {% trans "The ticket's status" %}
      • -
      • summary - {% trans "The ticket's summary" %}
      • -
      • version - {% trans "The ticket's version" %}
      • -
      -
      -
    • -
    • - wiki: - {% trans "Fields" %}: author, created, modified, modified_by, name and wiki_text -
        -
      • author - {% trans "The wiki's author username" %}
      • -
      • created - {% trans "When the wiki's were created" %}
      • -
      • modified - {% trans "The time of the last modification" %}
      • -
      • modified_by - {% trans "The username of the last user who modified the wiki" %}
      • -
      • name - {% trans "The wiki's name" %}
      • -
      • wiki_text - {% trans "the wiki's content" %}
      • -
      -
    • -
    -
  • -
-
    -
  • {% trans 'Parameters' %}:

  • -
  • -
  • -

    limit - {% trans "Results per page" %}

    - {% trans "Number of results to be displayed per page." %} - {% trans "Default: 20" %}. -
  • -
  • -
  • -

    offset - {% trans "Starts of n element" %}

    - {% trans "Where n is the index of the first result to appear in the page." %} - {% trans "Default: 0" %}. -
  • -
  • {% trans "Filtering" %}:

  • -
  • -

    fieldname - {% trans "The field name" %}

    - {% trans "If you are looking for a specific wiki, and you know the wiki's name, you can filter it as below" %} -

    ...{{ BASE_API_URL }}wiki/?name={% trans "WikiName" %}

    -

    {% trans "Where "name" is the fieldname and "WikiName" is the value you want to filter." %}

    -

    {% trans "Usage" %}

    -

    {% trans "You can also filter using Django lookup fields with the double underscores, just as below" %}

    -

    ...{{ BASE_API_URL }}wiki/?wiki_text__startswith={% trans "Wiki" %}

    -

    ...{{ BASE_API_URL }}ticket/?author__endswith={% trans "test" %}

    -

    ...{{ BASE_API_URL }}message/?body__contains={% trans "test" %}

    -

    {% trans "Usage with relationships" %}

    -

    {% 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" %}

    -

    ...{{ BASE_API_URL }}message/?from_address__real_name__contains=Name

    -

    {% 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" %}

    -

    {% trans "Note: email filters must be exact. Which means that __contains, __startswith, __endswith and others won't work" %}

    -

    {% trans "Another example of usage with relations. Used to retrieve all messages of a given user, using the username or the email field" %}

    -

    ...{{ BASE_API_URL }}message/?from_address__user__username=username

    -

    ...{{ BASE_API_URL }}message/?from_address__user__email=usermailexample@host.com

    -
  • -
-
-{% endblock %} diff --git a/colab/urls.py b/colab/urls.py index 888607e..ae2e4f8 100644 --- a/colab/urls.py +++ b/colab/urls.py @@ -8,31 +8,20 @@ from django.views.generic import RedirectView admin.autodiscover() urlpatterns = patterns('', + url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), - url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), - - url(r'^open-data/$', TemplateView.as_view(template_name='open-data.html'), - name='opendata'), - url(r'^search/', include('colab.search.urls')), - url(r'^archives/', include('colab.super_archives.urls')), url(r'^api/', include('colab.api.urls')), url(r'^rss/', include('colab.rss.urls')), - # Kept for backwards compatibility - url(r'^user/', include('colab.accounts.urls')), - # Kept for backwards compatibility - url(r'^user/', include('colab.accounts.urls')), - # (same here) TODO: move to nginx - url(r'^signup/', include('colab.accounts.urls')), url(r'^account/', include('colab.accounts.urls')), url(r'^myaccount/(?P.*)$', 'colab.accounts.views.myaccount_redirect', name='myaccount'), - # Uncomment the next line to enable the admin: url(r'^colab/admin/', include(admin.site.urls)), + url(r'^archives/', include('colab.super_archives.urls')), url(r'^gitlab/', include('colab.plugins.gitlab.urls')), url(r'^mezuro/', include('colab.plugins.mezuro.urls')), url(r'^social/', include('colab.plugins.noosfero.urls')), -- libgit2 0.21.2