Skip to content

Commit

Permalink
#212 Display issues on project page
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Dec 26, 2013
1 parent 6b50cdf commit 2ee9b99
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 29 deletions.
2 changes: 1 addition & 1 deletion djangoproject/core/services/issue_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def kickstart_new_issue(dict, user):
if(issue.project):
msg += "project : " + issue.project.name + "\n<br>" +\
"project.trackerURL: " + issue.project.trackerURL + "\n<br>"
notify_admin("INFO: New issue kickstarted", msg)
notify_admin("INFO: New issue proposed", msg)
return issue


Expand Down
5 changes: 4 additions & 1 deletion djangoproject/core/views/json_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ def get_offers(request):

def list_issue_cards(request):

project_id = None
if 'project_id' in request.GET:
project_id = int(request.GET.get('project_id'))
offset = int(request.GET.get('offset'))
count = int(request.GET.get('count'))
if not count:
count = 3
sponsoring = request.GET.get('sponsoring').lower() == 'true'
count = min(count, 100)
query = issue_services.search_issues(is_public_suggestion=not sponsoring)
query = issue_services.search_issues(project_id=project_id, is_public_suggestion=not sponsoring)
total_count = query.count()
issues = query[offset: offset + count]
issues = issue_services.to_card_dict(issues)
Expand Down
14 changes: 6 additions & 8 deletions djangoproject/core/views/main_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def logout(request):
"""Logs out user"""
auth_logout(request)
return HttpResponseRedirect('/')



def login(request):
getparams = ''
if request.GET.has_key('next') :
Expand Down Expand Up @@ -75,14 +76,11 @@ def mailtest(request):


def home(request):
_is_old_layout = is_old_layout(request)
size = 20 if _is_old_layout else 3
issues_sponsoring = issue_services.search_issues(is_public_suggestion=False)[0:size]
issues_kickstarting = issue_services.search_issues(is_public_suggestion=True)[0:size]
issues_sponsoring = issue_services.search_issues(is_public_suggestion=False)[0:3]
issues_kickstarting = issue_services.search_issues(is_public_suggestion=True)[0:3]
crumbs = [HOME_CRUMB]
if not _is_old_layout:
issues_sponsoring = json.dumps(issue_services.to_card_dict(issues_sponsoring))
issues_kickstarting = json.dumps(issue_services.to_card_dict(issues_kickstarting))
issues_sponsoring = json.dumps(issue_services.to_card_dict(issues_sponsoring))
issues_kickstarting = json.dumps(issue_services.to_card_dict(issues_kickstarting))
return render_to_response(template_folder(request) + 'home.html',
{'issues_sponsoring': issues_sponsoring,
'issues_kickstarting': issues_kickstarting,
Expand Down
10 changes: 8 additions & 2 deletions djangoproject/core/views/project_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from core.models import Project
from core.services import stats_services
from core.services import stats_services, issue_services
from core.signals import project_edited
from core.views import template_folder

Expand All @@ -12,10 +12,16 @@
def view(request, project_id):
project = Project.objects.get(pk=project_id)
stats = stats_services.project_stats(project)
issues_sponsoring = issue_services.search_issues(project_id=project_id, is_public_suggestion=False)[0:3]
issues_kickstarting = issue_services.search_issues(project_id=project_id, is_public_suggestion=True)[0:3]
issues_sponsoring = json.dumps(issue_services.to_card_dict(issues_sponsoring))
issues_kickstarting = json.dumps(issue_services.to_card_dict(issues_kickstarting))
return render_to_response('core2/project.html',
{'project': project,
'stats': stats,
'tags': json.dumps([t.name for t in project.get_tags()])},
'tags': json.dumps([t.name for t in project.get_tags()]),
'issues_sponsoring': issues_sponsoring,
'issues_kickstarting': issues_kickstarting,},
context_instance=RequestContext(request))


Expand Down
3 changes: 2 additions & 1 deletion djangoproject/statfiles/static/js/fsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ var fsapi_mod = angular.module('fsapi', []);

fsapi_mod.factory('FSApi', function(){

function list_issues(sponsoring, offset, count){
function list_issues(project_id, sponsoring, offset, count){
var params = {
project_id: project_id,
sponsoring: sponsoring,
offset: offset,
count: count
Expand Down
2 changes: 1 addition & 1 deletion djangoproject/statfiles/static/js/fsapi_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var fsapi_mod = angular.module('fsapi', []);

fsapi_mod.factory('FSApi', function(){

function list_issues(sponsoring, offset, count){
function list_issues(project_id, sponsoring, offset, count){
var issues = [];
for(var i=0; i < count; i++){
var issue = sponsoring ? randomSponsoredIssue() : randomProposedIssue();
Expand Down
8 changes: 8 additions & 0 deletions djangoproject/statfiles/static/js/fsutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ function fs_ajax_async_result(func, url, params){
});
return r;
}

function get4Sponsors(issue){
var empties = [];
for(var i=0; i<4 - issue.four_sponsors.length; i++){
empties.push({empty:true});
}
return empties.concat(issue.four_sponsors)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h3 class="boxed medium">{{ label }}</h3>
<a href class="fs-button square grey less" ng-class="{'disabled' : no_less()}" ng-click="less()">«</a>
<a href class="fs-button square grey more" ng-class="{'disabled' : no_more()}" ng-click="more()">»</a>
<img ng-show="is_loading" src="/static/img2/ajax-loader.gif">
<a href="/core/issue/?operation={[{getViewAllOperation()}]}" class="fs-button medium grey view-all right">View All</a>
<a href="/core/issue/?project_id={[{ projectId }]}&operation={[{getViewAllOperation()}]}" class="fs-button medium grey view-all right">View All</a>
</div>
<div class="column-wrapper">
<div ng-repeat="issue in issues" ng-include="getInclude()"></div>
Expand Down
5 changes: 3 additions & 2 deletions djangoproject/statfiles/static/js/issuecards/issuecards.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ mod.directive('issueCards', function() {
scope:{
issues: "=",
label: "@",
sponsoring: '@'
sponsoring: '@',
projectId: '@'
},
templateUrl: '/static/js/issuecards/issuecards.html',
controller: function ($scope, $rootScope, FSApi, FSLinks) {
Expand All @@ -41,7 +42,7 @@ mod.directive('issueCards', function() {

function load(){
$scope.is_loading = true;
FSApi.list_issues(is_sponsoring, $scope.offset, 3).onResult(function(result){
FSApi.list_issues($scope.projectId, is_sponsoring, $scope.offset, 3).onResult(function(result){
$scope.count = result.count;
$scope.issues = result.issues;
$scope.is_loading = false;
Expand Down
2 changes: 1 addition & 1 deletion djangoproject/templates/core/issue_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
checked
{% endifequal %}
>
<label for="rad_kickstarting">Kickstarting</label>
<label for="rad_kickstarting">Proposed</label>
</div>
<div class="span1 form-inline" style="">
<input type="radio" id="rad_both" name="operation" value="BOTH" style="margin-bottom:6px"
Expand Down
8 changes: 0 additions & 8 deletions djangoproject/templates/core2/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
}
);

function get4Sponsors(issue){
var empties = [];
for(var i=0; i<4 - issue.four_sponsors.length; i++){
empties.push({empty:true});
}
return empties.concat(issue.four_sponsors)
}

function HomeCtrl($scope) {
var issues_sponsoring = {{ issues_sponsoring|safe }};
for(var i=0; i < issues_sponsoring.length; i++){
Expand Down
34 changes: 31 additions & 3 deletions djangoproject/templates/core2/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
<script src="/static/js/angularutils/angularutils.js"></script>
<script src="/static/js/so/soapi.js"></script>
<script src="/static/js/tags/taglist.js"></script>
<script src="/static/js/issuecards/issuecards.js"></script>
<script src="/static/js/fsutil.js"></script>
{% if sandbox %}
<script src="/static/js/tags/tag_api_mock.js"></script>
<script src="/static/js/fsapi_mock.js"></script>
<script src="/static/js/fslinks_sandbox.js"></script>
{% else %}
<script src="/static/js/tags/tag_api.js"></script>
<script src="/static/js/fsapi.js"></script>
<script src="/static/js/fslinks.js"></script>
{% endif %}
<script src="/static/bootstrap/js/showdown.js"></script>
<script>

var dependencies = ['angularutils', 'taglist'];
var dependencies = ['issuecards', 'angularutils', 'taglist'];

var mod = angular.module('project', dependencies);
mod.config(
Expand All @@ -29,6 +35,16 @@
mod.controller("MyCtrl", function($scope){
$scope.tags = {{ tags|safe }};
$scope.authenticated = {% if user.is_authenticated %}true{% else %}false{% endif %};

var issues_sponsoring = {{ issues_sponsoring|safe }};
for(var i=0; i < issues_sponsoring.length; i++){
var issue = issues_sponsoring[i];
issue.four_sponsors_places = get4Sponsors(issue);
}

$scope.issues_sponsoring = issues_sponsoring;
$scope.issues_proposed = {{ issues_kickstarting|safe }};

});
</script>
{% endblock %}
Expand Down Expand Up @@ -162,15 +178,27 @@ <h4 class="arial">Total Issues</h4>

<!-- Tab's List -->
<ul class="tab-list" id="myTab">
<li class="active"><a href="#comunity" data-toggle="tab">Comunity</a></li>
<li class="active"><a href="#issues" data-toggle="tab">Issues</a></li>
<li><a href="#comunity" data-toggle="tab">Comunity</a></li>
<li><a href="#activities" data-toggle="tab">Activities</a></li>
</ul>

<!-- Tab's Content -->
<div class="tab-content">

<!-- Issues Tab -->
<div class="tab-pane active" id="issues">
<!-- Sponsored Issues -->
<issue-cards issues="issues_sponsoring" label="Sponsored Issues" sponsoring="true" project-id="{{ project.id }}"></issue-cards>

<div class="divider"><!-- Divider --></div>

<!-- Proposed Issues -->
<issue-cards issues="issues_proposed" label="Proposed Issues" sponsoring="false" project-id="{{ project.id }}"></issue-cards>
</div>

<!-- Comunity Tab -->
<div class="tab-pane active" id="comunity">
<div class="tab-pane" id="comunity">
<div class="fs-box">
<p>Insert some text about the community tab here. What people can do here?</p>
</div>
Expand Down

0 comments on commit 2ee9b99

Please sign in to comment.