Commit bf9c9ec3 authored by root's avatar root
Browse files

Merge branch 'dev' of https://code.grnet.gr/git/astakos into dev

parents bda1ad47 e0bab820
#Mon Sep 10 11:32:44 EEST 2012
#Thu Sep 27 13:01:48 EEST 2012
eclipse.preferences.version=1
encoding//astakos/im/migrations/0010_auto__add_field_astakosuser_activation_sent__chg_field_service_url.py=utf-8
encoding//astakos/im/migrations/0011_set_old_activation_sent.py=utf-8
encoding//astakos/im/migrations/0017_populate_resource_data.py=utf-8
encoding//astakos/im/migrations/0023_populate_resource_data.py=utf-8
......@@ -629,5 +629,21 @@ class TimelineForm(forms.Form):
class AstakosGroupSortForm(forms.Form):
sort_by = forms.ChoiceField(label='Sort by',
choices=(('groupname', 'Name'), ('kindname', 'Type')),
choices=(('groupname', 'Name'),
('kindname', 'Type'),
('issue_date', 'Issue Date'),
('expiration_date', 'Expiration Date'),
('approved_members_num', 'Participants'),
('is_enabled', 'Status'),
('moderation_enabled', 'Moderation'),
('membership_status','Enrollment Status')
),
required=False)
class MembersSortForm(forms.Form):
sort_by = forms.ChoiceField(label='Sort by',
choices=(('person__email', 'User Id'),
('person__first_name', 'Name'),
('date_joined', 'Status')
),
required=False)
......@@ -120,22 +120,17 @@ class AstakosGroup(Group):
'Homepage Url', max_length=255, null=True, blank=True)
desc = models.TextField('Description', null=True)
policy = models.ManyToManyField(Resource, null=True, blank=True,
through='AstakosGroupQuota'
)
through='AstakosGroupQuota')
creation_date = models.DateTimeField('Creation date',
default=datetime.now()
)
default=datetime.now())
issue_date = models.DateTimeField('Issue date', null=True)
expiration_date = models.DateTimeField('Expiration date', null=True)
moderation_enabled = models.BooleanField('Moderated membership?',
default=True
)
default=True)
approval_date = models.DateTimeField('Activation date', null=True,
blank=True
)
blank=True)
estimated_participants = models.PositiveIntegerField('Estimated #members',
null=True
)
null=True)
@property
def is_disabled(self):
......@@ -187,16 +182,18 @@ class AstakosGroup(Group):
@property
def members(self):
return [m.person for m in self.membership_set.all()]
q = self.membership_set.select_related().all()
return [m.person for m in q]
@property
def approved_members(self):
return [m.person for m in self.membership_set.all() if m.is_approved]
q = self.membership_set.select_related().all()
return [m.person for m in q if m.is_approved]
@property
def quota(self):
d = defaultdict(int)
for q in self.astakosgroupquota_set.all():
for q in self.astakosgroupquota_set.select_related().all():
d[q.resource] += q.uplimit
return d
......@@ -204,6 +201,10 @@ class AstakosGroup(Group):
def owners(self):
return self.owner.all()
@property
def owner_details(self):
return self.owner.select_related().all()
@owners.setter
def owners(self, l):
self.owner = l
......@@ -295,9 +296,9 @@ class AstakosUser(User):
@property
def quota(self):
d = defaultdict(int)
for q in self.astakosuserquota_set.all():
for q in self.astakosuserquota_set.select_related().all():
d[q.resource.name] += q.uplimit
for m in self.membership_set.all():
for m in self.membership_set.select_related().all():
if not m.is_approved:
continue
g = m.group
......
......@@ -152,4 +152,4 @@ SERVICES = getattr(settings, 'ASTAKOS_SERVICES',
AQUARIUM_URL = getattr(settings, 'ASTAKOS_AQUARIUM_URL', '')
# Set how many objects should be displayed per page
PAGINATE_BY = getattr(settings, 'ASTAKOS_PAGINATE_BY', 10)
\ No newline at end of file
PAGINATE_BY = getattr(settings, 'ASTAKOS_PAGINATE_BY', 8)
\ No newline at end of file
......@@ -152,6 +152,9 @@ form+p:first-child, form legend + p { margin-bottom:2em; }
form.link-like { display:inline-block; margin:0 5px; float:right;}
form.link-like input[type="submit"] { margin:0; padding:0 5px; background:transparent; color:#F89A1C; cursor:pointer; height:auto; }
form.link-like input[type="submit"]:hover { text-decoration:underline; }
form.link-like.alone { float:none; margin:0;}
form.link-like.alone .form-row { margin:0; }
form.link-like.alone input[type="submit"] { padding:0; }
.projects form.withlabels .checkbox-widget { margin-top:5px; }
.projects form .with-checkbox { margin:20px 0; }
.projects form .with-checkbox label { padding-top:7px; }
......
......@@ -286,11 +286,14 @@ dl.alt-style dt:nth-child(2n) { background:black; }
.details img { max-width:100%; }
.question .section { margin-top:1em; }
.question pre { border:1px dashed #000; padding:5px; margin:10px 0; line-height:auto; }
.widjets { margin: 0; padding:0; }
.widjets { position:relative; }
.widjets ul { margin: 0; padding:0; }
.widjets li { width:50%; float:left; list-style:none outside; margin:30px 0; }
.widjets li div { border:1px dashed #000; padding:20px 20px 70px; width:60%; margin:0 auto; position:relative; }
.widjets li div img { max-width:100%; }
.widjets li .btn { text-align:center; position:absolute; bottom:0; left:0; right:0; }
.widjets .widjet-x { position:absolute; right:0;top:0; font-weight:bold; font-size:1.5em; }
.widjets .widjet-x:hover { text-decoration:none; color:#000; }
/* billing styles */
.alt-style .table-div { border:1px dashed #000; }
......
......@@ -205,6 +205,13 @@ $(document).ready(function() {
$(this).hide();
})
$('.widjet-x').click(function(e){
e.preventDefault();
$(this).siblings('ul').hide('slow');
$(this).hide();
})
});
$(window).resize(function() {
......
......@@ -3,23 +3,25 @@
{% load filters %}
{% block page.body %}
{% with object.owners as owners %}
{% with object.quota as quota %}
<div class="projects">
<h2>
{% if request.user in object.members %}
{% if object.is_member %}
<em>
{% if request.user in object.owner.all %}
{% if object.is_owner %}
[ADMINISTRATOR]
{% else %}
[ ENROLLED ]
{% endif %}
</em>
{% endif %}
<span>[ {{object.kind|upper}} ]</span>
<span>[ {{object.kindname|upper}} ]</span>
</h2>
<div class="details">
{% if request.user in object.owner.all %}
{% if object.is_owner %}
<a href="#" class="edit">[ EDIT GROUP INFO ]</a>
{% endif %}
<div class="data">
......@@ -36,12 +38,14 @@
</dl>
</div>
<div class="editable" style="display:none;">
<form action="{% url astakos.im.views.group_update object.id %}" method="post"
<form action="" method="post"
class="withlabels">{% csrf_token %}
{% include "im/form_render.html" %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="FINISHED EDITING" />
</div>
{% with update_form as form %}
{% include "im/form_render.html" %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="FINISHED EDITING" />
</div>
{% endwith %}
</form>
</div>
</div>
......@@ -51,7 +55,7 @@
<dt>Name</dt>
<dd>{{object.name}}&nbsp;</dd>
<dt>Type</dt>
<dd>{{object.kind|capfirst}}&nbsp;</dd>
<dd>{{object.kindname|capfirst}}&nbsp;</dd>
<dt>Issue date:</dt>
<dd>{{object.issue_date|date:"d/m/Y"}}&nbsp;</dd>
<dt>Expiration Date</dt>
......@@ -61,8 +65,9 @@
<dt>Activated</dt>
<dd>{% if object.is_enabled %}Yes{% else %}No{% endif %}</dd>
<dt>Owner</dt>
<dd>{% for o in object.owner.all %}
{% if user == o %}
{{ o.owners }}
<dd>{% for o in owners %}
{% if object.is_owner %}
Me
{% else%}
{{o.realname}} ({{o.email}})
......@@ -90,50 +95,79 @@
{% endif %}
</div>
<div class="full-dotted">
{% if object.members %}
<table class="alt-style table_sorting">
<caption>MEMBERS:</caption>
<thead>
<tr>
<th>User Id</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for m in object.membership_set.all %}
<tr>
<td>{{m.person.email}}</td>
<td>{{m.person.realname}}</td>
{% if m.person in m.group.owner.all %}
<td>Owner</td>
{% else %}
{% if m.is_approved %}
<td>Approved</td>
{% with page|concat:sorting as args %}
{% with object.membership_set.select_related.all|paginate:args as membership %}
{% if membership %}
<form method="GET" class="minimal" action="">
<div class="form-row">
<select name="sorting" onchange="this.form.submit();">
<option value="">Sort by</option>
<option value="person__email" {% if sorting == 'person__email' %}selected{% endif %}>User Id</option>
<option value="person__first_name" {% if sorting == 'person__first_name' %}selected{% endif %}>Name</option>
<option value="date_joined" {% if sorting == 'date_joined' %}selected{% endif %}>Status</option>
</select>
</div>
</form>
<table class="alt-style">
<caption>MEMBERS:</caption>
<thead>
<tr>
<th>User Id</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for m in membership.object_list %}
<tr>
<td>{{m.person.email}}</td>
<td>{{m.person.realname}}</td>
{% if m.person in owners %}
<td>Owner</td>
{% else %}
<td>Pending
{% if user in m.group.owner.all %}
<a href="{% url approve_member m.group.id m.person.id %}">Accept</a>
<a href="{% url disapprove_member m.group.id m.person.id %}">Reject</a>
{% if m.is_approved %}
<td>Approved</td>
{% else %}
<td>Pending
{% if object.is_owner %}
<a href="{% url approve_member object.id m.person.id %}?{% if page %}page={{ page }}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">Accept</a>
<a href="{% url disapprove_member object.id m.person.id %}?{% if page %}page={{ page }}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">Reject</a>
{% endif %}
</td>
{% endif %}
</td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No members yet!</p>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<div class="pagination">
<p class="next-prev">
{% if membership.has_previous %}
<a href="?page={{ membership.previous_page_number }}{% if sorting %}&sorting={{sorting}}{% endif %}">previous</a>
{% endif %}
{% if membership.has_next %}
<a href="?page={{ membership.next_page_number }}{% if sorting %}&sorting={{sorting}}{% endif %}">next</a>
{% endif %}
</p>
<p class="nums">
<span class="current">
Page {{ membership.number }} of {{ membership.paginator.num_pages }}
</span>
</p>
</div>
{% else %}
<p>No members yet!</p>
{% endif %}
{% endwith %}
{% endwith %}
</div>
{% if user in object.owner.all %}
{% if object.is_owner %}
<div class="full-dotted">
<form action="{% url add_members object.id %}" method="post" class="withlabels">{% csrf_token %}
<form action="" method="post" class="withlabels">{% csrf_token %}
<h2>Enroll more members</h2>
{% with search_form as form %}
{% with addmembers_form as form %}
{% include "im/form_render.html" %}
{% endwith %}
<div class="form-row submit">
......@@ -145,4 +179,6 @@
</div>
{% endwith %}
{% endwith %}
{% endblock %}
......@@ -4,44 +4,61 @@
{% block page.body %}
<div class="maincol {% block innerpage.class %}{% endblock %}">
<h2>GROUPS</h2>
{% if form %}
<p>You can search for a group by name</p>
<form action="{% url group_search %}" method="post" class="withlabels signup">{% csrf_token %}
{% include "im/form_render.html" %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="SEARCH" />
</div>
</form>
<form action="{% url group_all %}" method="post" class="link-like">{% csrf_token %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="Show all groups" />
</div>
</form>
{% else %}
<div class="projects">
<!--<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <br />You can <a href="{% url group_create_list %}">create a new group</a> or <a href="{% url group_search %}">join</a> to an existing one.</p>
<ul class="widjets clearfix">
<li>
<div>
<p>WELCOME!<br />Connect with a world of people who share your passions.<br />With millions of groups at your fingertips, it's easy to find the group that's best for you -- no matter your interest.</p>
<p class="btn"><a href="{% url group_create_list %}" class="submit">CREATE</a></p>
</div>
</li>
<li>
<div>
<p>LOOKING FOR A GROUP?</p><p>Well, this is the place to start!</br>sdofuisd ofuaofi usdiof uiofu osifuaoi ufisdfiousf oiusd<br /><img alt="THINK ABOUT IT" src="/static/medialibrary/2012/06/behind_okeanos.png"></p>
<p class="btn"><a href="{% url group_search %}" class="submit">JOIN</a></p>
</div>
</li>
</ul>-->
<h2>GROUPS</h2>
{% if form %}
<p>You can search for a group by name</p>
<form action="{% url group_search %}" method="post" class="withlabels signup">{% csrf_token %}
{% include "im/form_render.html" %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="SEARCH" />
</div>
</form>
<form action="{% url group_all %}" method="post" class="link-like alone">{% csrf_token %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="Show all groups" />
</div>
</form>
{% else %}
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <br>You can <a href="{% url group_create_list %}">create a new group</a> or <a href="{% url group_search %}">join</a> to an existing one.</p>
<div class="widjets">
<a href="#" class="widjet-x" title="remove boxes">X</a>
<ul class="clearfix">
<li>
<div>
<p>WELCOME!<br>Connect with a world of people who share your passions.<br>With millions of groups at your fingertips, it's easy to find the group that's best for you -- no matter your interest.</p>
<p class="btn"><a href="{% url group_create_list %}" class="submit">CREATE</a></p>
</div>
</li>
<li>
<div>
<p>LOOKING FOR A GROUP?</p><p>Well, this is the place to start!<br>sdofuisd ofuaofi usdiof uiofu osifuaoi ufisdfiousf oiusd<br><img alt="THINK ABOUT IT" src="/static/medialibrary/2012/06/behind_okeanos.png"></p>
<p class="btn"><a href="{% url group_search %}" class="submit">JOIN</a></p>
</div>
</li>
</ul>
</div>
{% endif %}
{% with page_obj.object_list as object_list %}
<!-- Search group -->
{% if object_list %}
<div class="full-dotted">
<form method="GET" class="minimal" action="">
<div class="form-row">
<select name="sorting" onchange="this.form.submit();">
<option value="">Sort by</option>
<option value="groupname" {% if sorting == 'groupname' %}selected{% endif %}>Name</option>
<option value="kindname" {% if sorting == 'kindname' %}selected{% endif %}>Type</option>
<option value="issue_date" {% if sorting == 'issue_date' %}selected{% endif %}>Issue date</option>
<option value="expiration_date" {% if sorting == 'expiration_date' %}selected{% endif %}>Expiration Date</option>
<option value="approved_members_num" {% if sorting == 'approved_members_num' %}selected{% endif %}>Participants</option>
</select>
<input type="hidden" name="q" value="{{q}}"/>
</div>
</form>
<table class="alt-style complex">
<caption>
SEARCH RESULTS
......@@ -75,9 +92,11 @@
{% if o.membership_approval_date %}
Registered
<form action="{% url group_leave o.id %}" method="post" class="link-like">{% csrf_token %}
<input type="submit" value="LEAVE GROUP" />
</form>
{% if not o.is_owner %}
<form action="{% url group_leave o.id %}" method="post" class="link-like">{% csrf_token %}
<input type="submit" value="LEAVE GROUP" />
</form>
{% endif %}
......@@ -95,13 +114,12 @@
<td><a href="#" class="more-info" title="more info">&nbsp;</a></td>
</tr>
<tr class="{% cycle 'tmore1' 'tmore2' %}" style="display:none">
<td colspan="8" class="info-td">
<td colspan="7" class="info-td">
<div>
<p>{{o.desc}}</p>
<p>{% if o.homepage%}
Visit it group's home page: <a target="_blank" href="{{ o.homepage }}">{{ o.homepage }}</a>
{% else %}
There is no homepage for this group yet.
Group's home page: <a target="_blank" href="{{ o.homepage }}">{{ o.homepage }}</a>
{% endif %}
</p>
</div>
......@@ -117,10 +135,10 @@
<div class="pagination">
<p class="next-prev">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}{% if q %}&q={{q}}{% endif %}">previous</a>
<a href="?page={{ page_obj.previous_page_number }}{% if q %}&q={{q}}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">previous</a>
{% endif %}
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}{% if q %}&q={{q}}{% endif %}">next</a>
<a href="?page={{ page_obj.next_page_number }}{% if q %}&q={{q}}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">next</a>
{% endif %}
</p>
<p class="nums">
......@@ -129,19 +147,27 @@
</span>
</p>
</div>
{% else %}
{% if mine %}
<!-- Group listing -->
{% else %}
{% if mine %}
{% with own_page|concat:own_sorting as args %}
{% with mine|paginate:args as mine %}
<div class="full-dotted">
<form method="GET" class="minimal" action="">
<div class="form-row">
<select name="own_sorting" onchange="this.form.submit();">
<option value="">Sort by</option>
<option value="groupname" {% if own_sorting == 'groupname' %}selected{% endif %}>Name</option>
<option value="kindname" {% if own_sorting == 'kindname' %}selected{% endif %}>Type</option>
<option value="kindname" {% if own_sorting == 'kindname' %}selected{% endif %}>Type</option>
<option value="issue_date" {% if own_sorting == 'issue_date' %}selected{% endif %}>Issue date</option>
<option value="expiration_date" {% if own_sorting == 'expiration_date' %}selected{% endif %}>Expiration Date</option>
<option value="approved_members_num" {% if own_sorting == 'approved_members_num' %}selected{% endif %}>Participants</option>
<option value="is_enabled" {% if own_sorting == 'is_enabled' %}selected{% endif %}>Status</option>
<option value="moderation_enabled" {% if own_sorting == 'moderation_enabled' %}selected{% endif %}>Moderation</option>
</select>
</div>
</form>
<table class="alt-style complex" id="">
<table class="alt-style complex">
<caption>MY GROUPS</caption>
<thead>
<tr>
......@@ -173,9 +199,7 @@
<div>
<p>{{o.desc}}</p>
<p>{% if o.homepage%}
Visit it group's home page: <a href="{{ o.homepage }}">{{ o.homepage }}</a>
{% else %}
There is no homepage for this group yet.
Group's home page: <a href="{{ o.homepage }}">{{ o.homepage }}</a>
{% endif %}
</p>
</div>
......@@ -200,9 +224,14 @@
</span>
</p>
</div>
{% endwith %}
{% endwith %}
{% endif %}
{% if other %}
{% if other %}
{% with other_page|concat:other_sorting as args %}
{% with other|paginate:args as other %}
<div class="full-dotted">
<form method="GET" class="minimal" action="">
<div class="form-row">
......@@ -210,6 +239,11 @@
<option value="">Sort by</option>
<option value="groupname" {% if other_sorting == 'groupname' %}selected{% endif %}>Name</option>
<option value="kindname" {% if other_sorting == 'kindname' %}selected{% endif %}>Type</option>
<option value="issue_date" {% if other_sorting == 'issue_date' %}selected{% endif %}>Issue date</option>
<option value="expiration_date" {% if other_sorting == 'expiration_date' %}selected{% endif %}>Expiration Date</option>
<option value="approved_members_num" {% if other_sorting == 'approved_members_num' %}selected{% endif %}>Participants</option>
<option value="membership_status" {% if other_sorting == 'membership_status' %}selected{% endif %}>Enrollment Status</option>
</select>
</div>
</form>
......@@ -223,6 +257,7 @@
<th>Type</th>
<th>Issued</th>
<th>Expires</th>
<th>Enrolled</th>
......@@ -243,14 +278,12 @@
<td>{{ o.approved_members_num }}</td>
<td>
{% if o.membership_approval_date %}
Registered
{% if o.membership_status %}
Registered
<form action="{% url group_leave o.id %}" method="post" class="link-like">{% csrf_token %}
<input type="submit" value="LEAVE GROUP" />
</form>
{% else %}
Pending
{% endif %}
......@@ -258,7 +291,7 @@
<td><a href="#" class="more-info" title="more info">&nbsp;</a></td>
</tr>
<tr class="{% cycle 'tmore1' 'tmore2' %}" style="display:none">
<td colspan="8" class="info-td">
<td colspan="7" class="info-td">
<div>
<p>{{o.desc}}</p>
<p>{% if o.homepage%}
......@@ -290,8 +323,11 @@
</span>
</p>
</div>
{% endwith %}
{% endwith %}
{% endif %}