+ {% for field in form %}
+
+
+
+ {{ field }}
+ {{ field.errors }}
+
+
{% endfor %}
- {% for email in user_.emails_not_validated.iterator %}
-
- {% gravatar user_.email 30 %}
- {{ email.address }}
-
-
-
+
+
+
+
+
+
{% trans "Emails" %}
+
+
+
+
+
+
-
-
- {% endfor %}
-
-
-
-
+
+
-
-
-
-
-
-
- {% trans 'Change Password' %}
-
+
+
+
+
+ {% trans 'Change Password' %}
+
+
+
+
-
+
-
+
+
+
+ {% content_xpto %}
-
-
-
-
+
+
Some content in menu 2.
-
+
+
+
+
+
{% endblock %}
diff --git a/colab/accounts/views.py b/colab/accounts/views.py
index 5b206e8..71fb6e8 100644
--- a/colab/accounts/views.py
+++ b/colab/accounts/views.py
@@ -15,6 +15,7 @@ from colab.super_archives.models import (EmailAddress,
EmailAddressValidation)
from colab.search.utils import get_collaboration_data, get_visible_threads
from colab.accounts.models import User
+from colab.plugins.utils.widget_manager import WidgetManager
from .forms import (UserCreationForm, ListsForm, UserUpdateForm)
from .utils import mailman
@@ -42,6 +43,13 @@ class UserProfileUpdateView(UserProfileBaseMixin, UpdateView):
return obj
+ def get_context_data(self, **kwargs):
+ context = {}
+ context['widgets'] = WidgetManager.get_widgets('profile', self.request)
+ context['lala'] = 'lala123'
+ context.update(kwargs)
+ return super(UserProfileUpdateView, self).get_context_data(**context)
+
class UserProfileDetailView(UserProfileBaseMixin, DetailView):
template_name = 'accounts/user_detail.html'
diff --git a/colab/plugins/gitlab/__init__.py b/colab/plugins/gitlab/__init__.py
new file mode 100644
index 0000000..58d7ecd
--- /dev/null
+++ b/colab/plugins/gitlab/__init__.py
@@ -0,0 +1,8 @@
+
+
+default_app_config = 'colab.plugins.gitlab.apps.ProxyGitlabAppConfig'
+
+from colab.plugins.utils.widget_manager import WidgetManager
+from colab.plugins.gitlab.widgets import GitlabProfileWidget
+
+WidgetManager.register_widget('profile', GitlabProfileWidget())
diff --git a/colab/plugins/gitlab/profile/diazo.xml b/colab/plugins/gitlab/profile/diazo.xml
new file mode 100644
index 0000000..61577ef
--- /dev/null
+++ b/colab/plugins/gitlab/profile/diazo.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ /account//edit?code=/
+
+
+ /account//edit?code=/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/colab/plugins/gitlab/templates/proxy/gitlab_profile.html b/colab/plugins/gitlab/templates/proxy/gitlab_profile.html
new file mode 100644
index 0000000..d68d406
--- /dev/null
+++ b/colab/plugins/gitlab/templates/proxy/gitlab_profile.html
@@ -0,0 +1,50 @@
+
+{% load static from staticfiles %}
+
+{% block head_css %}
+
+{% endblock %}
+
+{% block head_js %}
+
+{% endblock %}
+
+
+
+
diff --git a/colab/plugins/gitlab/urls.py b/colab/plugins/gitlab/urls.py
new file mode 100644
index 0000000..5dfa370
--- /dev/null
+++ b/colab/plugins/gitlab/urls.py
@@ -0,0 +1,10 @@
+
+from django.conf.urls import patterns, url
+
+from .views import GitlabProxyView, GitlabProfileProxyView
+
+urlpatterns = patterns('',
+ # Gitlab URLs
+ #url(r'(?P
profile.*)$', GitlabProfileProxyView.as_view(), name='gitlab'),
+ url(r'^(?P.*)$', GitlabProxyView.as_view(), name='gitlab'),
+)
diff --git a/colab/plugins/gitlab/views.py b/colab/plugins/gitlab/views.py
new file mode 100644
index 0000000..ba980a8
--- /dev/null
+++ b/colab/plugins/gitlab/views.py
@@ -0,0 +1,22 @@
+
+from ..utils.views import ColabProxyView
+import os, sys
+
+
+class GitlabProxyView(ColabProxyView):
+ app_label = 'gitlab'
+ diazo_theme_template = 'proxy/gitlab.html'
+
+
+class GitlabProfileProxyView(ColabProxyView):
+ app_label = 'gitlab'
+ diazo_theme_template = 'proxy/gitlab_profile.html'
+
+ @property
+ def diazo_rules(self):
+ child_class_file = sys.modules[self.__module__].__file__
+ app_path = os.path.abspath(os.path.dirname(child_class_file))
+ diazo_path = os.path.join(app_path, 'profile/diazo.xml')
+
+ self.log.debug("diazo_rules: %s", diazo_path)
+ return diazo_path
diff --git a/colab/plugins/gitlab/widgets.py b/colab/plugins/gitlab/widgets.py
new file mode 100644
index 0000000..9415a6f
--- /dev/null
+++ b/colab/plugins/gitlab/widgets.py
@@ -0,0 +1,21 @@
+from colab.plugins.gitlab.views import GitlabProxyView, GitlabProfileProxyView
+from colab.plugins.utils.widget_manager import Widget
+from django.utils.safestring import mark_safe
+
+
+class GitlabProfileWidget(GitlabProxyView, Widget):
+ identifier = 'code'
+ name = 'Gitlab Profile'
+ default_url = '/gitlab/profile/account'
+
+ def generate_content(self, request):
+ requested_url = request.GET.get('code', self.default_url)
+ g = GitlabProfileProxyView()
+ r = g.dispatch(request, requested_url)
+ if r.status_code == 302:
+ location = r.get('Location')
+ requested_url = location[location.find('/{}/'.format(self.app_label)):]
+ request.method = 'GET'
+ r = g.dispatch(request, requested_url)
+
+ return "" + r.content + "
"
\ No newline at end of file
diff --git a/colab/plugins/templatetags/plugins.py b/colab/plugins/templatetags/plugins.py
index 62c83bb..61279b5 100644
--- a/colab/plugins/templatetags/plugins.py
+++ b/colab/plugins/templatetags/plugins.py
@@ -51,3 +51,23 @@ def plugins_menu(context):
cache.set(cache_key, menu)
return menu
+
+import requests
+from django.conf import settings
+from colab.plugins.gitlab.views import GitlabProfileProxyView
+@register.simple_tag(takes_context=True)
+def content_xpto(context):
+ request = context['request']
+ requested_url = request.GET.get('code', '/gitlab/profile/account')
+ print "requested_url1 = " + requested_url
+
+ g = GitlabProfileProxyView()
+ r = g.dispatch(request, requested_url)
+ if r.status_code == 302:
+ location = r.get('Location')
+ requested_url = location[location.find('/gitlab/'):]
+ request.method = 'GET'
+ print "requested_url2 = " + requested_url
+ r = g.dispatch(request, requested_url)
+
+ return "" + r.content + "
"
diff --git a/colab/plugins/utils/widget_manager.py b/colab/plugins/utils/widget_manager.py
new file mode 100644
index 0000000..9e8b65d
--- /dev/null
+++ b/colab/plugins/utils/widget_manager.py
@@ -0,0 +1,44 @@
+
+class Widget:
+ identifier = None
+ name = None
+ default_url = None
+ content = None
+
+ def get_body(self):
+ # avoiding regex in favor of performance
+ start = content.find('')
+ end = content.find('')
+ head = content[start + len(''):end]
+ return head
+
+ def get_header(self):
+ # avoiding regex in favor of performance
+ start = content.find('')
+ end = content.find('')
+ head = content[start + len(''):end]
+ return head
+
+ def generate_content(self, request=None):
+ self.content = ''
+
+
+class WidgetManager(object):
+ widget_categories = {}
+
+ @staticmethod
+ def register_widget(category, widget):
+ if not WidgetManager.widget_categories.has_key(category):
+ WidgetManager.widget_categories[category] = []
+
+ WidgetManager.widget_categories[category].append(widget)
+
+ @staticmethod
+ def get_widgets(category, request=None):
+ if not WidgetManager.widget_categories.has_key(category):
+ return []
+
+ widgets = WidgetManager.widget_categories[category]
+ for widget in widgets:
+ widget.generate_content(request)
+ return widgets
diff --git a/colab/urls.py b/colab/urls.py
index bd9e229..9e10f74 100644
--- a/colab/urls.py
+++ b/colab/urls.py
@@ -3,7 +3,7 @@ from django.conf import settings
from django.views.generic import TemplateView
from django.contrib import admin
from django.views.generic import RedirectView
-
+from accounts.views import UserProfileUpdateView
admin.autodiscover()
diff --git a/diagrama_classes.asta b/diagrama_classes.asta
new file mode 100644
index 0000000..2f2c42c
Binary files /dev/null and b/diagrama_classes.asta differ
--
libgit2 0.21.2