Commits

Matthew Marshall committed 8d3dd5d Merge

merge

Comments (0)

Files changed (19)

hgfront/member/urls.py

     url(r'^login/$','member_login', name='member-login'),
     url(r'^logout/$','member_logout', name='member-logout'),
     url(r'^home/$','member_home', name='member-home'),
+    url(r'^profile/(?P<member_name>[-\w]+)/$','member_profile', name='member-profile'),
     url(r'^passwordreset/$','member_password', name='member-password'),
     url(r'^verifyusername/$','member_verifyusername', name='member-verifyusername'),
     url(r'^verifyuseremail/$','member_verifyuseremail', name='member-verifyuseremail'),

hgfront/member/views.py

     return HttpResponseRedirect(reverse('project-list'))
 
 def member_home(request):
-    user = auth.get_user(request)
+    user = request.user
     member = Member.objects.get(member_user = user)
     
     user_projects_owns = Project.objects.filter(user_owner__exact = user)
          'user_projects_owns': user_projects_owns
         }, context_instance=RequestContext(request)
     )
+    
+def member_profile(request, member_name):
+    user = User.objects.get(username__exact = member_name)
+    member = Member.objects.get(member_user__exact = user)
+    
+    user_projects_owns = Project.objects.filter(user_owner__exact = user)
+    return render_to_response('member/profile.html',
+        {
+         'user': user,
+         'member': member,
+         'user_projects_owns': user_projects_owns
+        }, context_instance=RequestContext(request)
+    )
+
 
 def member_password(request):
     if request.method == 'POST':

hgfront/project/urls.py

 
 # Issues
 urlpatterns += patterns('',
-    url(r'^(?P<slug>[-\w]+)/issues/', include('hgfront.issue.urls')),
-    url(r'^(?P<slug>[-\w]+)/repos/', include('hgfront.repo.urls')),
-    url(r'^(?P<slug>[-\w]+)/wiki/',include('hgfront.wiki.urls')),
-    url(r'^(?P<slug>[-\w]+)/backup/', include('hgfront.backup.urls')),
+    url(r'^(?P<slug>[-\w]+)/i/', include('hgfront.issue.urls')),
+    url(r'^(?P<slug>[-\w]+)/r/', include('hgfront.repo.urls')),
+    url(r'^(?P<slug>[-\w]+)/w/',include('hgfront.wiki.urls')),
+    url(r'^(?P<slug>[-\w]+)/b/', include('hgfront.backup.urls')),
 )

hgfront/project/views.py

 def get_project_list(request):
     projects = [project for project in Project.objects.select_related()if project.get_permissions(request.user).view_project]
     project_news = ProjectNews.objects.filter(frontpage=True, authorised=True).order_by('-pub_date')[:2]
+    user_can_request_to_join = ProjectPermissionSet.objects.filter(project=project, user__id=request.user.id).count()<1 and request.user.is_authenticated() and request.user != project.user_owner
     
     return render_to_response('project/project_list.html',
         {
             'projects': projects,
-            'project_news': project_news
+            'project_news': project_news,
+            'user_can_request_to_join':user_can_request_to_join
         }, context_instance=RequestContext(request)
     )
 
 
 def join_project(request, slug):
     project = get_object_or_404(Project.objects.select_related(), name_short = slug)
-    if request.method == 'POST' and request.user.is_authenticated():
+    if request.user.is_authenticated():
         permissionset, created = ProjectPermissionSet.objects.get_or_create(is_default=False, user=request.user, project=project)
         if created:
             permissionset.user_accepted = True
         request.user.message_set.create(message='You have requested to join this project!')
         return HttpResponseRedirect(project.get_absolute_url())
     else:
-        return HttpResponse('Must be called via post and you must be logged in')
+        return HttpResponse('You must register or login to join a project')
         
 def add_project_news(request, slug):
     project = get_object_or_404(Project.objects.select_related(), name_short = slug)

hgfront/templates/account/profile.html

-<div class="profile-view">
-	<h2>Profile for {{user.username}}</h2>
-
-</div>

hgfront/templates/base.html

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title>{% block title %}{{hgf_site_name}}{% endblock %}</title>
-    <link rel="stylesheet" href="/hgfront/static/blueprint/screen.css" type="text/css" media="screen, projection">
-    <link rel="stylesheet" href="/hgfront/static/blueprint/print.css" type="text/css" media="print">    
+    <link rel="stylesheet" href="/static/blueprint/screen.css" type="text/css" media="screen, projection">
+    <link rel="stylesheet" href="/static/blueprint/print.css" type="text/css" media="print">    
     <!--[if IE]>
         <link rel="stylesheet" href="/hgfront/static/blueprint/ie.css" type="text/css" media="screen, projection">
     <![endif]-->
-    <link rel="stylesheet" type="text/css" href="/hgfront/static/style.css" />
-    <script type="text/javascript" src="/hgfront/static/js/jquery.js"></script>
-    <script type="text/javascript" src="/hgfront/static/js/hgfront.js"></script>
+    <link rel="stylesheet" type="text/css" href="/static/style.css" />
+    <script type="text/javascript" src="/static/js/jquery.js"></script>
+    <script type="text/javascript" src="/static/js/hgfront.js"></script>
 </head>
 
 <body>
             <span class="userbar">
                 {% if hgf_logged_in_user %}
                     {{hgf_logged_in_user}} (
-						<a href="/hgfront/member/logout/">Logout</a>
+						<a href="{% url member-logout %}">Logout</a>
 						{% if user.is_staff %} | <a href="/admin/">Admin</a> {% endif %}
 						)
                 {% else %}
-                    <a href="/hgfront/member/login/">Login</a> / <a href="/hgfront/member/register/" class="link-create-user">Register</a>
+                    <a href="{% url member-login %}">Login</a> / <a href="{% url member-register %}" class="link-create-user">Register</a>
                 {% endif %}
             </span>
             
         <div class="span-24" id="breadcrumbs">
             <ul>
                 {% block breadcrumbs %}
-                    <li class="home"><a href="/hgfront/projects/">Home</a></li>            
+                    <li class="home"><a href="{% url project-list %}">Home</a></li>            
                 {% endblock breadcrumbs %}
             </ul>
         </div>

hgfront/templates/elements/search_form.html

 {% load core_templatetags %}
 
 {% menubox "Search" %}
-<form action="/hgfront/search/" method="post">
+<form action="/s/" method="post">
     <input type="text" id="search_term" name="search_term" />
     <input type="submit" value="search" />
 </form>

hgfront/templates/issue/issue_detail.html

     {% if permissions.edit_issues %}<a href="{% url issue-edit slug=project.name_short, issue_id=issue.id %}">Edit this issue</a>{% endif %}
     <form method="post" action="{% url issue-edit slug=project.name_short, issue_id=issue.id %}">
         <input type="hidden" name="toggling_completed" value="1" />
-        <input type="submit" value="{{issue.completed|yesno:"Repoen,Mark as completed"}}" />
+        <input type="submit" value="{{issue.completed|yesno:"Re-open,Mark as completed"}}" />
     </form>
 
 {% endblock main_content %}

hgfront/templates/member/member_register.html

 
 {% block main_content %}
 
-<script type="text/javascript" src="/hgfront/static/js/jquery.pstrength.js"></script>
-<script type="text/javascript" src="/hgfront/static/js/jquery.validate.min.js"></script>
+<script type="text/javascript" src="/static/js/jquery.pstrength.js"></script>
+<script type="text/javascript" src="/static/js/jquery.validate.min.js"></script>
 <script type="text/javascript">
 	$(document).ready(function(){
 		$('#member-register').validate({
 					required: true,
 					minlength: 4,
 					maxlength: 25,
-					remote: "/hgfront/member/verifyusername/"
+					remote: "{% url member-verifyusername %}"
 				},
 				member_email : {
 					required: true,
 					email: true,
-					remote: "/hgfront/member/verifyuseremail/"
+					remote: "{% url member-verifyuseremail %}"
 				},
 				member_password : {
 					required: true

hgfront/templates/member/profile.html

+{% extends "base.html" %}
+{% load core_templatetags %}
+
+{% block title %}{{block.super}} {{user}}'s Profile{% endblock %}
+
+{% block content_title %}{{user}}'s Profile{% endblock %}
+{% block breadcrumbs %}{{block.super}} {{user}}'s Profile{% endblock %}
+
+{% block main_content %}
+
+    <h3>Project that belong to {{user}}</h3>
+	<table>
+		<thead>
+			<tr>
+				<th>Project Name</th>
+				<th># Repos</th>
+				<th># Members</th>
+			</tr>
+		</thead>
+		<tbody>
+			{% for project in user_projects_owns %}
+				<tr>
+					<td><a href="{{project.get_absolute_url}}">{{project.name_long}}</a></td>
+					<td>{{project.num_repos}}</td>
+					<td>{{project.members.count}}</td>
+				</tr>
+			{% endfor %}
+		</tbody>
+	</table>
+	<h3>Issues assigned to {{user}}</h3>
+{% endblock %}

hgfront/templates/project/project_create.html

 {% block breadcrumbs %}{{block.super}}<li class="project-add">&raquo; <a href="{% url project-create %}">New project</a></li>{% endblock %}
 
 {% block main_content %}
-	<script type="text/javascript" src="/hgfront/static/js/jquery.validate.min.js"></script>
+	<script type="text/javascript" src="/static/js/jquery.validate.min.js"></script>
 	<script type="text/javascript">
 		$(document).ready(function(){
 			$('#project-create-step-1').validate({
 						required: true,
 						minlength: 4,
 						maxlength: 25,
-						remote: '/hgfront/projects/verifyprojectshortname/'
+						remote: '/p/verifyprojectshortname/'
 					}
 				},
 				messages : {

hgfront/templates/project/project_list.html

 
 
 	{% if projects %}
-	<table>
-	<thead>
-		<tr>
-			<th>Project Name</th>
-			<th>Description</th>
-			<th>Active Since</th>
-			<th>Project Owner</th>
-		</tr>
-	</thead>
-	<tbody>
+	<ul>
 		{% for project in projects %}
-				<tr>
-					<td><a href="{{project.get_absolute_url}}">{{project.name_long}}</a></td>
-					<td>{{project.description_short|truncatewords_html:10}}</td>
-					<td>{{project.pub_date|date:"d M Y"}}</td>
-					<td><a href="{{project.user_owner.get_absolute_url}}">{{project.user_owner}}</a></td>
-				</tr>
+				<li class="bubbleInfo">
+					<a class="trigger" href="{{project.get_absolute_url}}">{{project.name_long}}</a>
+					<div class="popup">
+						<div class="popup-content">
+							<dl>
+								<dt>Project Description</dt>
+								<dd>{{project.description_short|truncatewords_html:10}}</dd>
+								<dt>Project Owner</dt>
+								<dd><a href="{% url member-profile %}/{{project.user_owner}}/">{{project.user_owner}}</a></dd>
+								<dt>Creation Date</dt>
+								<dd>{{project.pub_date|date:"d M Y"}}</dd>
+							</dl>
+							<a class="link-open-project" href="{{project.get_absolute_url}}">Open Project</a>
+							{% if user_can_request_to_join %}
+								<a class="link-join-project" href="{% url project-join-project slug=project.name_short %}">Join Project</a>
+	    					{% endif %}
+						</div>
+ 	 				</div>
+				</li>
 		{% endfor %}
-	</tbody>
-	</table>
+	</ul>
 	{% else %}
 		<strong>There are currently no projects on the system.</strong>
 	{% endif %}

hgfront/templates/static/images/coda-popup.png

Added
New image

hgfront/templates/static/images/projects/join.png

Added
New image

hgfront/templates/static/images/projects/open.png

Added
New image

hgfront/templates/static/js/hgfront.js

     version : 0.1,
     authors : "Tane Piper &amp; Miran Lipovaca"
 }
+
+$(function () {
+  $('.bubbleInfo').each(function () {
+    // options
+    var distance = 10;
+    var time = 250;
+    var hideDelay = 200;
+
+    var hideDelayTimer = null;
+
+    // tracker
+    var beingShown = false;
+    var shown = false;
+    
+    var trigger = $('.trigger', this);
+    var popup = $('.popup', this).css('opacity', 0);
+
+    // set the mouseover and mouseout on both element
+    $([trigger.get(0), popup.get(0)]).mouseover(function () {
+      // stops the hide event if we move from the trigger to the popup element
+      if (hideDelayTimer) clearTimeout(hideDelayTimer);
+
+      // don't trigger the animation again if we're being shown, or already visible
+      if (beingShown || shown) {
+        return;
+      } else {
+        beingShown = true;
+
+        // reset position of popup box
+        popup.css({
+          top: -100,
+          left: -33,
+          display: 'block' // brings the popup back in to view
+        })
+
+        // (we're using chaining on the popup) now animate it's opacity and position
+        .animate({
+          top: '-=' + distance + 'px',
+          opacity: 1
+        }, time, 'swing', function() {
+          // once the animation is complete, set the tracker variables
+          beingShown = false;
+          shown = true;
+        });
+      }
+    }).mouseout(function () {
+      // reset the timer if we get fired again - avoids double animations
+      if (hideDelayTimer) clearTimeout(hideDelayTimer);
+      
+      // store the timer so that it can be cleared in the mouseover if required
+      hideDelayTimer = setTimeout(function () {
+        hideDelayTimer = null;
+        popup.animate({
+          top: '-=' + distance + 'px',
+          opacity: 0
+        }, time, 'swing', function () {
+          // once the animate is complete, set the tracker variables
+          shown = false;
+          // hide the popup entirely after the effect (opacity alone doesn't do the job)
+          popup.css('display', 'none');
+        });
+      }, hideDelay);
+    });
+  });
+});

hgfront/templates/static/style.css

     padding: 5px 0 5px 25px;
 }
 
+.link-open-project {
+    background: url('images/projects/open.png') no-repeat;
+    padding: 5px 0 5px 25px;
+}
+
+.link-join-project {
+    background: url('images/projects/join.png') no-repeat;
+    padding: 5px 0 5px 25px;
+}
+
 /* Forms */
 
 label {
     background: url('images/help.png') no-repeat 40px;
     border-top: 1px dotted #f00;
 }
+
+/* Coda Popup */
+.bubbleInfo {
+    position: relative;
+}
+
+.popup {
+    position: absolute;
+    display: none; /* keeps the popup hidden if no JS available */
+	background: url('images/coda-popup.png') no-repeat center center;
+	width: 250px;
+	height: 187px;
+}
+
+.popup-content {
+	padding: 20px 10px;
+}
+
 # Project Libraries
 
 urlpatterns = patterns('',
-	url(r'^projects/',include('hgfront.project.urls')),
+	url(r'^p/',include('hgfront.project.urls')),
 	url(r'^config/', include('hgfront.config.urls')),
-	url(r'^member/',include('hgfront.member.urls')),
-	url(r'^search/', include('hgfront.search.urls')),
+	url(r'^u/',include('hgfront.member.urls')),
+	url(r'^s/', include('hgfront.search.urls')),
 )
-#static content
-urlpatterns += patterns('',
-    url(r'^static/(?P<path>.*)$','django.views.static.serve',{'document_root':settings.HGFRONT_STATIC_PATH})
-)
+from django.conf import settings
 from django.conf.urls.defaults import *
 
 urlpatterns = patterns('',
-    url(r'^admin/',include('django.contrib.admin.urls')),
-    url(r'^hgfront/',include('hgfront.urls')),
-    url(r'^login/', 'django.contrib.auth.views.login', {'template_name':'login.html'}, name='login-screen')
+    url(r'^admin/',include('django.contrib.admin.urls'), name='admin'),
+    url(r'^',include('hgfront.urls')),
+    url(r'^login/', 'django.contrib.auth.views.login', {'template_name':'login.html'}, name='login-screen'),
+    url(r'^static/(?P<path>.*)$','django.views.static.serve',{'document_root':settings.HGFRONT_STATIC_PATH}, name='static-content')
 )
 
 # TODO this should be optional