Commit 43f94cc0 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

Fix sequence of project applications & project search

parent d98f15ff
......@@ -1031,5 +1031,5 @@ class ProjectMembersSortForm(forms.Form):
required=True
)
class ProjectGroupSearchForm(forms.Form):
class ProjectSearchForm(forms.Form):
q = forms.CharField(max_length=200, label='Search project')
\ No newline at end of file
......@@ -52,8 +52,8 @@ class Command(NoArgsCommand):
def handle_noargs(self, **options):
apps = ProjectApplication.objects.select_related().all()
labels = ('id', 'name', 'state')
columns = (3, 40, 10)
labels = ('application.id', 'project.id', 'name', 'state')
columns = (15, 10, 20, 10)
if not options['csv']:
line = ' '.join(l.rjust(w) for l, w in zip(labels, columns))
......@@ -62,8 +62,13 @@ class Command(NoArgsCommand):
self.stdout.write(sep + '\n')
for app in apps:
try:
project_id = str(app.project.id)
except:
project_id = ''
fields = (
str(app.id),
str(project_id),
app.definition.name,
app.state
)
......
......@@ -1197,6 +1197,7 @@ class ProjectApplication(models.Model):
precursor_application_id = precursor_application.id
application = precursor_application
application.id = None
application.precursor_application = None
else:
application = ProjectApplication(owner=applicant)
application.definition = definition
......@@ -1256,10 +1257,15 @@ class ProjectApplication(models.Model):
project.application = self
project.last_approval_date = datetime.now()
project.save()
self.precursor_application.state = REPLACED
self.definition.validate_name()
precursor = self.precursor_application
while precursor:
precursor.state = REPLACED
precursor.save()
precursor = precursor.precursor_application
self.state = APPROVED
self.save()
# self.definition.validate_name()
notification = build_notification(
settings.SERVER_EMAIL,
......@@ -1280,7 +1286,7 @@ class ProjectApplication(models.Model):
if rejected:
raise Exception(_(astakos_messages.QH_SYNC_ERROR))
else:
project.last_application_synced = app
project.last_application_synced = self
project.save()
......
......@@ -55,7 +55,7 @@
{% endif %}
{% with page_obj.object_list as object_list %}
<!-- Search group -->
<!-- Search project -->
{% if object_list %}
<div class="full-dotted">
<form method="GET" class="minimal" action="#searchResults">
......@@ -99,7 +99,7 @@
{% with o.project.members.all as members %}
{% with o.project.approved_members as approved_members%}
<tr class="{% cycle 'tr1' 'tr2' %}">
<td style="width:22%"><a href="{% url project_detail o.id %}" title="visit group page">{{o.definition.name|truncatename}}</a></td>
<td style="width:22%"><a href="{% url project_detail o.id %}" title="visit project page">{{o.definition.name|truncatename}}</a></td>
<!--td>{{o.kindname|capfirst}}</td-->
<td style="width:13%">{{o.issue_date|date:"d/m/Y"}}</td>
<td style="width:13%">{{o.definition.start_date|date:"d/m/Y"}}</td>
......@@ -135,8 +135,8 @@
<input type="submit" value="x leave group" class="leave"/>
</form>
<div class="dialog">
Are you sure you what to leave this group?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.groupname}}</a><br>
Are you sure you what to leave this project?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.definition.name}}</a><br>
{% if o.definition.description %}Description:{{o.definition.description|truncatewords:30}}{% endif %}<br><br>
<a href="#" class="yes submit">Yes</a>&nbsp;&nbsp;&nbsp;<a href="#" class="no submit">No</a>
</div>
......@@ -152,8 +152,8 @@
<input type="submit" value="+ join group" class="join_group join" />
</form>
<div class="dialog">
Are you sure you what to join this group?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.groupname}}</a><br>
Are you sure you what to join this project?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.definition.name}}</a><br>
{% if o.definition.description %}Description:{{o.definition.description|truncatewords:30}}{% endif %}<br><br>
<a href="#" class="yes submit">Yes</a>&nbsp;&nbsp;&nbsp;<a href="#" class="no submit">No</a>
......@@ -289,8 +289,8 @@
<input type="submit" value="x leave" class="leave" />
</form>
<div class="dialog">
Are you sure you want to leave this group?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.groupname}}</a><br>
Are you sure you want to leave this project?<br>
Name: <a href="{% url project_detail o.id %}" title="visit group page">{{o.definition.name}}</a><br>
{% if o.definition.description %}Description:{{o.definition.description|truncatewords:30}}{% endif %}<br><br>
<a href="#" class="yes submit">Yes</a>&nbsp;&nbsp;&nbsp;<a href="#" class="no submit">No</a>
......
......@@ -82,7 +82,7 @@ from astakos.im.forms import (
TimelineForm, PickResourceForm,
AstakosGroupCreationSummaryForm,
ProjectApplicationForm, ProjectSortForm,
AddProjectMembersForm, ProjectGroupSearchForm
AddProjectMembersForm, ProjectSearchForm
)
from astakos.im.functions import (
send_feedback, SendMailError,
......@@ -1588,15 +1588,16 @@ def project_detail(request, id):
@signed_terms_required
@login_required
def project_search(request):
queryset = ProjectApplication.objects.none()
queryset = ProjectApplication.objects
if request.method == 'GET':
form = AstakosGroupSearchForm()
form = ProjectSearchForm()
queryset = queryset.none()
else:
form = AstakosGroupSearchForm(request.POST.get('q'))
form = ProjectSearchForm(request.POST)
if form.is_valid():
q = form.cleaned_data['q'].strip()
queryset = filter(~Q(project__last_approval_date__isnull=True))
queryset = queryset.filter(name__contains=q)
queryset = queryset.filter(~Q(project__last_approval_date__isnull=True))
queryset = queryset.filter(definition__name__contains=q)
sorting = 'definition__name'
# validate sorting
sort_form = AstakosGroupSortForm(request.GET)
......@@ -1608,7 +1609,7 @@ def project_search(request):
queryset,
paginate_by=PAGINATE_BY_ALL,
page=request.GET.get('page') or 1,
template_name='im/astakosgroup_list.html',
template_name='im/projects/project_list.html',
extra_context=dict(
form=form,
is_search=True,
......@@ -1623,7 +1624,6 @@ def project_search(request):
def project_all(request):
q = ProjectApplication.objects.filter(~Q(project__last_approval_date__isnull=True))
q = q.select_related()
sorting = 'definition__name'
sort_form = ProjectSortForm(request.GET)
if sort_form.is_valid():
......@@ -1637,7 +1637,7 @@ def project_all(request):
page=request.GET.get('page') or 1,
template_name='im/projects/project_list.html',
extra_context={
'form':ProjectGroupSearchForm(),
'form':ProjectSearchForm(),
'is_search':True,
'sorting':sorting
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment