Revision a5cef8d0
b/snf-astakos-app/astakos/im/models.py | ||
---|---|---|
1100 | 1100 |
return self.filter(Q(owner=user) | Q(applicant=user) | \ |
1101 | 1101 |
Q(project__in=user.projectmembership_set.filter())) |
1102 | 1102 |
|
1103 |
def search_by_name(self, *search_strings): |
|
1104 |
q = Q() |
|
1105 |
for s in search_strings: |
|
1106 |
q = q | Q(name__icontains=s) |
|
1107 |
return self.filter(q) |
|
1108 |
|
|
1109 |
|
|
1103 | 1110 |
class ProjectApplication(models.Model): |
1104 | 1111 |
PENDING, APPROVED, REPLACED, UNKNOWN = 'Pending', 'Approved', 'Replaced', 'Unknown' |
1105 | 1112 |
applicant = models.ForeignKey( |
... | ... | |
1153 | 1160 |
try: |
1154 | 1161 |
membership = self.project.projectmembership_set.get(person=user) |
1155 | 1162 |
status = membership.state |
1156 |
except Project.DoesNotExist: |
|
1163 |
except ProjectMembership.DoesNotExist:
|
|
1157 | 1164 |
status = -1 |
1158 | 1165 |
|
1159 | 1166 |
return status |
b/snf-astakos-app/astakos/im/tables.py | ||
---|---|---|
3 | 3 |
from django.utils.translation import ugettext as _ |
4 | 4 |
from django_tables2 import A |
5 | 5 |
from astakos.im.models import * |
6 |
from django.utils.safestring import mark_safe |
|
6 | 7 |
|
7 | 8 |
DEFAULT_DATE_FORMAT = "d/m/Y" |
8 | 9 |
|
... | ... | |
35 | 36 |
issue_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) |
36 | 37 |
start_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) |
37 | 38 |
state = tables.Column(verbose_name="Status") |
38 |
members_count = tables.Column(verbose_name="Enrolled", default=0) |
|
39 |
members_count = tables.Column(verbose_name="Enrolled", default=0, |
|
40 |
sortable=False) |
|
39 | 41 |
membership_status = tables.Column(verbose_name="My status", empty_values=(), |
40 | 42 |
orderable=False) |
41 | 43 |
|
b/snf-astakos-app/astakos/im/templates/im/projects/intro.html | ||
---|---|---|
1 |
<div class="two-cols clearfix"> |
|
2 |
<div class="rt"> |
|
3 |
|
|
4 |
</div> |
|
5 |
<div class="lt"> |
|
6 |
<p>~okeanos gives the opportunity to Greek Academic or Research Organizations/Institutions/Faculty to run their own projects remotely on virtual infrastructure. Simple, fast and with minimal to no cost at all.</p> |
|
7 |
<p><a href="{% url how_it_works %}" style="font-size:1.154em;">How it works ></a></p> |
|
8 |
</div> |
|
9 |
</div> |
|
10 |
|
|
11 |
|
|
12 |
<div class="widjets"> |
|
13 |
<!--<a href="#" class="widjet-x" title="remove boxes">X</a>--> |
|
14 |
<ul class="clearfix"> |
|
15 |
<li class="create"> |
|
16 |
<div> |
|
17 |
<div class="wrap"> |
|
18 |
|
|
19 |
<p class="centered"><a href="{% url project_add %}"><img alt="THINK ABOUT IT" src="/static/im/images/create.png"></a></p> |
|
20 |
<p class="txt">Create a new Project in seconds. Specify how many members it will have, which and how many virtual resources it will provide to its members. Describe its purpose. Submit your request and if accepted, you and your colleagues are ready to deploy!<br><br> </p> |
|
21 |
<p><a href="{% url project_add %}">create a project ></a></p> |
|
22 |
</div> |
|
23 |
</div> |
|
24 |
</li> |
|
25 |
<li class="join"> |
|
26 |
<div> |
|
27 |
<div class="wrap"> |
|
28 |
<p class="centered"><a href="{% url project_search %}"><img alt="THINK ABOUT IT" src="/static/im/images/join.png"></a></p> |
|
29 |
<p class="txt">Become a member of an existing Project and instantly gain access to the resources it has to offer you. Search for open Projects and join for free. Contact the closed Projects administrators, if you think they will accept you. In two words: try to Join now. </p> |
|
30 |
|
|
31 |
<p><a href="{% url project_search %}">join a project ></a></p> |
|
32 |
</div> |
|
33 |
</div> |
|
34 |
</li> |
|
35 |
</ul> |
|
36 |
</div> |
b/snf-astakos-app/astakos/im/templates/im/projects/project_list.html | ||
---|---|---|
9 | 9 |
<div class="projects"> |
10 | 10 |
<h2>PROJECTS</h2> |
11 | 11 |
{% if form %} |
12 |
{% include "im/projects_list.html" %}
|
|
12 |
{% include "im/projects/search_form.html" %}
|
|
13 | 13 |
{% else %} |
14 |
{% include "im/projects_index.html" %}
|
|
14 |
{% include "im/projects/intro.html" %}
|
|
15 | 15 |
</div> |
16 |
{% endif %} |
|
17 |
{% render_table table %} |
|
16 |
{% endif %} |
|
17 |
{% if table %} |
|
18 |
{% render_table table %} |
|
19 |
{% endif %} |
|
18 | 20 |
</div> |
19 | 21 |
</div> |
20 | 22 |
{% endblock %} |
b/snf-astakos-app/astakos/im/templates/im/projects/search_form.html | ||
---|---|---|
1 |
<p>Search for existing Projects and join the ones you like. Please search by Project name. </p> |
|
2 |
<form action="{% url project_search %}" method="post" class="withlabels signup submit-inline">{% csrf_token %} |
|
3 |
{% include "im/form_render.html" %} |
|
4 |
<div class="form-row submit"> |
|
5 |
<input type="submit" class="submit altcol" value="SEARCH" /> |
|
6 |
{% if q %}<a href="{% url project_search %}">clear</a>{% endif %} |
|
7 |
</div> |
|
8 |
</form> |
|
9 |
|
/dev/null | ||
---|---|---|
1 |
<div class="two-cols clearfix"> |
|
2 |
<div class="rt"> |
|
3 |
|
|
4 |
</div> |
|
5 |
<div class="lt"> |
|
6 |
<p>~okeanos gives the opportunity to Greek Academic or Research Organizations/Institutions/Faculty to run their own projects remotely on virtual infrastructure. Simple, fast and with minimal to no cost at all.</p> |
|
7 |
<p><a href="{% url how_it_works %}" style="font-size:1.154em;">How it works ></a></p> |
|
8 |
</div> |
|
9 |
</div> |
|
10 |
|
|
11 |
|
|
12 |
<div class="widjets"> |
|
13 |
<!--<a href="#" class="widjet-x" title="remove boxes">X</a>--> |
|
14 |
<ul class="clearfix"> |
|
15 |
<li class="create"> |
|
16 |
<div> |
|
17 |
<div class="wrap"> |
|
18 |
|
|
19 |
<p class="centered"><a href="{% url project_add %}"><img alt="THINK ABOUT IT" src="/static/im/images/create.png"></a></p> |
|
20 |
<p class="txt">Create a new Project in seconds. Specify how many members it will have, which and how many virtual resources it will provide to its members. Describe its purpose. Submit your request and if accepted, you and your colleagues are ready to deploy!<br><br> </p> |
|
21 |
<p><a href="{% url project_add %}">create a project ></a></p> |
|
22 |
</div> |
|
23 |
</div> |
|
24 |
</li> |
|
25 |
<li class="join"> |
|
26 |
<div> |
|
27 |
<div class="wrap"> |
|
28 |
<p class="centered"><a href="{% url project_search %}"><img alt="THINK ABOUT IT" src="/static/im/images/join.png"></a></p> |
|
29 |
<p class="txt">Become a member of an existing Project and instantly gain access to the resources it has to offer you. Search for open Projects and join for free. Contact the closed Projects administrators, if you think they will accept you. In two words: try to Join now. </p> |
|
30 |
|
|
31 |
<p><a href="{% url project_search %}">join a project ></a></p> |
|
32 |
</div> |
|
33 |
</div> |
|
34 |
</li> |
|
35 |
</ul> |
|
36 |
</div> |
/dev/null | ||
---|---|---|
1 |
{% extends "im/account_base.html" %} |
|
2 |
|
|
3 |
{% load astakos_tags %} |
|
4 |
{% load filters %} |
|
5 |
{% load django_tables2 %} |
|
6 |
|
|
7 |
{% block page.body %} |
|
8 |
<div class="maincol {% block innerpage.class %}{% endblock %}"> |
|
9 |
<div class="projects"> |
|
10 |
<h2>PROJECTS</h2> |
|
11 |
{% if form %} |
|
12 |
{% include "im/projects_list.html" %} |
|
13 |
{% else %} |
|
14 |
{% include "im/projects_index.html" %} |
|
15 |
</div> |
|
16 |
{% endif %} |
|
17 |
{% render_table table %} |
|
18 |
</div> |
|
19 |
</div> |
|
20 |
{% endblock %} |
/dev/null | ||
---|---|---|
1 |
<p>Search for existing Projects and join the ones you like. Please search by Project name. </p> |
|
2 |
<form action="{% url project_search %}" method="post" class="withlabels signup submit-inline">{% csrf_token %} |
|
3 |
{% include "im/form_render.html" %} |
|
4 |
<div class="form-row submit"> |
|
5 |
<input type="submit" class="submit altcol" value="SEARCH" /> |
|
6 |
{% if q %}<a href="{% url project_search %}">clear</a>{% endif %} |
|
7 |
</div> |
|
8 |
</form> |
|
9 |
|
b/snf-astakos-app/astakos/im/views.py | ||
---|---|---|
41 | 41 |
from functools import wraps |
42 | 42 |
from datetime import datetime |
43 | 43 |
|
44 |
from django_tables2 import RequestConfig |
|
45 |
|
|
44 | 46 |
from django.shortcuts import get_object_or_404 |
45 | 47 |
from django.contrib import messages |
46 | 48 |
from django.contrib.auth.decorators import login_required |
... | ... | |
1086 | 1088 |
def project_add(request): |
1087 | 1089 |
result = callpoint.list_resources() |
1088 | 1090 |
details_fields = ["name", "homepage", "description","start_date","end_date", "comments"] |
1089 |
membership_fields =["member_join_policy", "member_leave_policy", "limit_on_members_number"]
|
|
1091 |
membership_fields =["member_join_policy", "member_leave_policy", "limit_on_members_number"] |
|
1090 | 1092 |
if not result.is_success: |
1091 | 1093 |
messages.error( |
1092 | 1094 |
request, |
... | ... | |
1097 | 1099 |
extra_context = {'resource_catalog':resource_catalog, 'show_form':True, 'details_fields':details_fields, 'membership_fields':membership_fields} |
1098 | 1100 |
return _create_object(request, template_name='im/projects/projectapplication_form.html', |
1099 | 1101 |
extra_context=extra_context, post_save_redirect=reverse('project_list'), |
1100 |
form_class=ProjectApplicationForm)
|
|
1102 |
form_class=ProjectApplicationForm) |
|
1101 | 1103 |
|
1102 | 1104 |
|
1103 | 1105 |
@require_http_methods(["GET"]) |
... | ... | |
1106 | 1108 |
def project_list(request): |
1107 | 1109 |
projects = ProjectApplication.objects.user_projects(request.user).select_related() |
1108 | 1110 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, prefix="my_projects") |
1109 |
table.paginate(page=request.GET.get('my_projectspage', 1), per_page=PAGINATE_BY)
|
|
1111 |
RequestConfig(request).configure(table)
|
|
1110 | 1112 |
|
1111 | 1113 |
return object_list( |
1112 | 1114 |
request, |
... | ... | |
1124 | 1126 |
def project_update(request, application_id): |
1125 | 1127 |
result = callpoint.list_resources() |
1126 | 1128 |
details_fields = ["name", "homepage", "description","start_date","end_date", "comments"] |
1127 |
membership_fields =["member_join_policy", "member_leave_policy", "limit_on_members_number"]
|
|
1129 |
membership_fields =["member_join_policy", "member_leave_policy", "limit_on_members_number"] |
|
1128 | 1130 |
if not result.is_success: |
1129 | 1131 |
messages.error( |
1130 | 1132 |
request, |
... | ... | |
1132 | 1134 |
) |
1133 | 1135 |
else: |
1134 | 1136 |
resource_catalog = result.data |
1135 |
extra_context = {'resource_catalog':resource_catalog, 'show_form':True, 'details_fields':details_fields, 'membership_fields':membership_fields} |
|
1137 |
extra_context = {'resource_catalog':resource_catalog, 'show_form':True, |
|
1138 |
'details_fields':details_fields, |
|
1139 |
'membership_fields':membership_fields} |
|
1136 | 1140 |
return _update_object( |
1137 | 1141 |
request, |
1138 | 1142 |
object_id=application_id, |
... | ... | |
1213 | 1217 |
@login_required |
1214 | 1218 |
def project_search(request): |
1215 | 1219 |
q = request.GET.get('q', '') |
1216 |
queryset = ProjectApplication.objects.filter() |
|
1220 |
form = ProjectSearchForm() |
|
1221 |
q = q.strip() |
|
1217 | 1222 |
|
1218 |
if request.method == 'GET': |
|
1219 |
form = ProjectSearchForm() |
|
1220 |
q = q.strip() |
|
1221 |
queryset = queryset.filter(~Q(project__last_approval_date__isnull=True)) |
|
1222 |
queryset = queryset.filter(name__contains=q) |
|
1223 |
else: |
|
1223 |
if request.method == "POST": |
|
1224 | 1224 |
form = ProjectSearchForm(request.POST) |
1225 |
|
|
1226 | 1225 |
if form.is_valid(): |
1227 | 1226 |
q = form.cleaned_data['q'].strip() |
1228 |
queryset = queryset.filter(~Q(project__last_approval_date__isnull=True)) |
|
1229 |
queryset = queryset.filter(name__contains=q) |
|
1230 | 1227 |
else: |
1231 |
queryset = queryset.none() |
|
1228 |
q = None |
|
1229 |
|
|
1230 |
if q is None: |
|
1231 |
projects = ProjectApplication.objects.none() |
|
1232 |
else: |
|
1233 |
projects = ProjectApplication.objects.search_by_name(q) |
|
1234 |
projects = projects.filter(~Q(project__last_approval_date__isnull=True)) |
|
1235 |
|
|
1236 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, prefix="my_projects") |
|
1237 |
RequestConfig(request).configure(table) |
|
1232 | 1238 |
|
1233 |
sorting = 'name' |
|
1234 |
# validate sorting |
|
1235 |
sort_form = ProjectSortForm(request.GET) |
|
1236 |
if sort_form.is_valid(): |
|
1237 |
sorting = sort_form.cleaned_data.get('sorting') |
|
1238 |
queryset = queryset.order_by(sorting) |
|
1239 |
|
|
1240 | 1239 |
return object_list( |
1241 | 1240 |
request, |
1242 |
queryset, |
|
1243 |
paginate_by=PAGINATE_BY_ALL, |
|
1244 |
page=request.GET.get('page') or 1, |
|
1241 |
projects, |
|
1245 | 1242 |
template_name='im/projects/project_list.html', |
1246 |
extra_context=dict( |
|
1247 |
form=form, |
|
1248 |
is_search=True, |
|
1249 |
sorting=sorting, |
|
1250 |
q=q, |
|
1251 |
) |
|
1252 |
) |
|
1243 |
extra_context={ |
|
1244 |
'form': form, |
|
1245 |
'is_search': True, |
|
1246 |
'q': q, |
|
1247 |
'table': table |
|
1248 |
}) |
|
1253 | 1249 |
|
1254 | 1250 |
@require_http_methods(["POST"]) |
1255 | 1251 |
@signed_terms_required |
Also available in: Unified diff