Skip to content

Commit

Permalink
Start profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
EnTeQuAk committed Sep 29, 2013
1 parent 395da2f commit 08e20c6
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 75 deletions.
9 changes: 9 additions & 0 deletions bakery/cookies/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import re
import urllib
from datetime import datetime, timedelta
from django.contrib.auth import get_user_model
from django.db import models
Expand Down Expand Up @@ -58,6 +59,10 @@ class Meta:
def __str__(self):
return self.name

def get_absolute_url(self):
# TODO
return ''

@property
def full_name(self):
return "{0}/{1}".format(self.owner_name, self.name)
Expand All @@ -69,6 +74,10 @@ def short_description(self):
descr = self.description
return _punctuation.split(descr)[0]

@property
def repo_title(self):
return urllib.parse.urlsplit(self.url).path.lstrip('/')

@property
def activity(self):
if self.last_change >= (datetime.utcnow() - timedelta(days=365)):
Expand Down
Empty file removed bakery/profiles/__init__.py
Empty file.
21 changes: 0 additions & 21 deletions bakery/profiles/admin.py

This file was deleted.

19 changes: 0 additions & 19 deletions bakery/profiles/contest_processors.py

This file was deleted.

8 changes: 0 additions & 8 deletions bakery/profiles/forms.py

This file was deleted.

8 changes: 0 additions & 8 deletions bakery/profiles/models.py

This file was deleted.

16 changes: 0 additions & 16 deletions bakery/profiles/tests.py

This file was deleted.

1 change: 0 additions & 1 deletion bakery/profiles/views.py

This file was deleted.

2 changes: 0 additions & 2 deletions bakery/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'social.apps.django_app.context_processors.backends',
)
Expand All @@ -126,7 +125,6 @@
'bakery.auth',
'bakery.cookies',
'bakery.socialize',
'bakery.profiles',
)

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
Expand Down
39 changes: 39 additions & 0 deletions bakery/templates/profiles/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends "base.html" %}

{% load url from future %}
{% load i18n %}

{% block head_title %}Profile for {{ bakery_user.sername }}{% endblock %}

{% block content %}
<div class="container">
<div class="row">
<div class="col-xs-2">
<h2>{% blocktrans %}<span class="fn nickname">{{ bakery_user.username }}</span>{% endblocktrans %}</h2>
</div>

<div class="col-xs-5">
{% if bakery_user.cookie_set.exists %}
<h3>{% trans "Cookies" %}</h3>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>{% trans "Package" %}</th>
<th>{% trans "Repo" %}</th>
</tr>
</thead>
<tbody>
{% for cookie in bakery_user.cookie_set.all %}
<tr>
<td>{{ forloop.counter }}</td>
<td><a href="{{ cookie.get_absolute_url }}">{{ cookie.name }}</a></td>
<td><a href="{{ cookie.url }}">{{ cookie.repo_title }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions bakery/templates/profiles/profile_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "base.html" %}

{% load url from future %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block head_title %}Profile form for {{ profile.user.username }}{% endblock %}

{% block body %}

{% crispy form helper %}

{% endblock body %}
76 changes: 76 additions & 0 deletions bakery/templates/profiles/profiles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{% extends "base.html" %}

{% load url from future %}
{% load i18n %}
{% load pagination_tags %}
{% load sorting_tags %}
{% load profile_tags %}

{% block head_title %}{% trans "All Profiles" %}{% endblock %}

{% block body %}

<h2>{% trans "All Profiles" %}</h2>

<p>{% trans "Click table headers to sort" %}</p>

{% autosort users %}
{% autopaginate users %}
{% paginate %}

<table id="home-packages">

{{ request.user.admin }}

<thead>
<tr>
<th>{% anchor username User Name %}</th>
<th>{% anchor date_joined Date Joined %}</th>
<th>{% anchor is_staff Staff %}</th>
{% if request.user.is_staff %}
<th>{% trans "Active" %}</th>
{% endif %}
<th>{% trans "Github" %}</th>
<th>{% trans "BitBucket" %}</th>
</tr>
</thead>

<tbody>
{% for user in users %}
{% with user.get_profile as profile %}
<tr>
<td>

{% if profile.github_account %}<a href="{% url 'profile_detail' profile.github_account %}">{{ profile.github_account }}</a>
{% else %}
{{ user.username }}
{% endif %}
</td>
<td><span class="hide">{{ user.date_joined|date:"YmdHis" }}</span>{{ user.date_joined|timesince }}</td>
<td>
{% if user.is_staff %}
<img src="{{ STATIC_URL }}img/icon-yes.gif" />
{% else %}
<img src="{{ STATIC_URL }}img/icon-no.gif" />
{% endif %}
</td>
{% if request.user.is_staff %}
<td>
{% if user.is_active %}
<img src="{{ STATIC_URL }}img/icon-yes.gif" />
{% else %}
<img src="{{ STATIC_URL }}img/icon-no.gif" />
{% endif %}
</td>
{% endif %}
<td><a href="https://github.com/{{ profile.github_account|default:"" }}">{{ profile.github_account|default:"" }}</a</td>
<td><a href="https://bitbucket.org/{{ profile.bitbucket_url|default:"" }}">{{ profile.bitbucket_url|default:"" }}</a</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>

{% paginate %}

{% endblock %}
2 changes: 2 additions & 0 deletions bakery/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
url(r'^styles/$', 'bakery.views.styles', name='styles'),
url(r'^login-error/$', 'bakery.views.login_error', name='login_error'),

url(r'^profile/(?P<username>.*?)/$', 'bakery.views.profile', name='profile'),

url(r'^', include('bakery.cookies.urls', namespace='cookies')),
url(r'^', include('bakery.socialize.urls', namespace='socialize')),
url('api/v1/', include('bakery.api.urls', namespace='api')),
Expand Down
13 changes: 13 additions & 0 deletions bakery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.views.generic import ListView, TemplateView, RedirectView
from django.contrib import auth

from bakery.auth.models import BakeryUser
from bakery.cookies.models import Cookie
from bakery.socialize.models import Vote

Expand Down Expand Up @@ -42,3 +43,15 @@ def get_redirect_url(self, **kwargs):
return reverse('home')

logout = LogoutView.as_view()


class ProfileView(TemplateView):
template_name = 'profiles/profile.html'

def get_context_data(self, **kwargs):
context = super(ProfileView, self).get_context_data(**kwargs)
user = BakeryUser.objects.get(username=kwargs['username'])
context['bakery_user'] = user
return context

profile = ProfileView.as_view()

0 comments on commit 08e20c6

Please sign in to comment.