New (reduced) create view, editing charter text in form
- Legacy-Id: 3411
This commit is contained in:
parent
743150dcfa
commit
b400d48e31
|
@ -4,7 +4,7 @@
|
|||
{% if wg %}
|
||||
Edit info on {{ wg.acronym }}
|
||||
{% else %}
|
||||
Create WG record
|
||||
Create WG
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ Copyright The IETF Trust 2011, All Rights Reserved
|
|||
{% endifequal %}{% endifequal %}
|
||||
|
||||
{% ifnotequal wg.state_id "conclude" %}
|
||||
<span id="wg_edit_info_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url wg_edit_info name=wg.acronym %}">Edit</a></span></span>
|
||||
<span id="wg_edit_info_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url wg_edit_info name=wg.acronym %}">Edit WG</a></span></span>
|
||||
{% endifnotequal %}
|
||||
|
||||
{% ifnotequal wg.state_id "conclude" %}
|
||||
<span id="wg_edit_info_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url wg_submit name=wg.acronym %}">Submit charter</a></span></span>
|
||||
<span id="wg_edit_info_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url wg_submit name=wg.acronym %}">Edit charter</a></span></span>
|
||||
{% endifnotequal %}
|
||||
</div>
|
||||
{% endif %}{# if not snapshot #}
|
||||
|
|
|
@ -71,7 +71,7 @@ Snapshots: {% if not snapshot %}<strong>{% else %}<a href="{% url wg_view_record
|
|||
<h3>Charter {{ charter.name }}-{{ rev }}</h3>
|
||||
|
||||
<div class="markup_draft">
|
||||
{{ content|safe }}
|
||||
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{# Copyright The IETF Trust 2007, All Rights Reserved #}
|
||||
{# Copyright The IETF Trust 2011, All Rights Reserved #}
|
||||
|
||||
{% block title %}Chartering States{% endblock %}
|
||||
{% block title %}Charter States{% endblock %}
|
||||
|
||||
{% block morecss %}
|
||||
.state_column {
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
<h1>Chartering States</h1>
|
||||
<h1>Charter States</h1>
|
||||
|
||||
<table class="ietf-table">
|
||||
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block morecss %}
|
||||
form #id_content {
|
||||
width: 40em;
|
||||
height: 600px;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
Charter submission for {{ wg.acronym }}
|
||||
{% endblock %}
|
||||
|
@ -15,6 +22,7 @@ Charter submission for {{ wg.acronym }}
|
|||
<th>{{ field.label_tag }}:</th>
|
||||
<td>
|
||||
{{ field }}
|
||||
{% if field.help_text %}<div class="help">{{ field.help_text }}</div>{% endif %}
|
||||
{{ field.errors }}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -172,8 +172,17 @@ class EditInfoForm(forms.Form):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.cur_acronym = kwargs.pop('cur_acronym')
|
||||
if 'hide' in kwargs:
|
||||
self.hide = kwargs.pop('hide')
|
||||
else:
|
||||
self.hide = None
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
|
||||
# hide requested fields
|
||||
if self.hide:
|
||||
for f in self.hide:
|
||||
self.fields[f].widget = forms.HiddenInput
|
||||
|
||||
# fix up ad field
|
||||
choices = self.fields['ad'].choices
|
||||
ex_ads = dict((e.pk, e) for e in Person.objects.filter(email__role__name="ex-ad").distinct())
|
||||
|
@ -388,10 +397,12 @@ def edit_info(request, name=None):
|
|||
comments=wg.comments if wg.comments else None,
|
||||
telechat_date=initial_telechat_date,
|
||||
)
|
||||
hide = None
|
||||
else:
|
||||
init = dict(ad=login.id,
|
||||
)
|
||||
form = EditInfoForm(initial=init, cur_acronym=wg.acronym if wg else None)
|
||||
hide = ['chairs', 'techadv', 'list_email', 'list_subscribe', 'list_archive', 'urls', 'telechat_date']
|
||||
form = EditInfoForm(initial=init, cur_acronym=wg.acronym if wg else None, hide=hide)
|
||||
|
||||
return render_to_response('wgrecord/edit_info.html',
|
||||
dict(wg=wg,
|
||||
|
|
|
@ -17,18 +17,27 @@ from django.conf import settings
|
|||
from utils import next_revision, set_or_create_charter, save_charter_in_history
|
||||
|
||||
class UploadForm(forms.Form):
|
||||
txt = forms.FileField(label=".txt format", required=True)
|
||||
content = forms.CharField(widget=forms.Textarea, label="Charter text", help_text="Edit the charter text", required=False)
|
||||
txt = forms.FileField(label=".txt format", help_text="Or upload a .txt file", required=False)
|
||||
|
||||
def clean_content(self):
|
||||
return self.cleaned_data["content"].replace("\r", "")
|
||||
|
||||
def save(self, wg, rev):
|
||||
for ext in ['txt']:
|
||||
fd = self.cleaned_data[ext]
|
||||
if not fd:
|
||||
continue
|
||||
filename = os.path.join(settings.CHARTER_PATH, 'charter-ietf-%s-%s.%s' % (wg.acronym, rev, ext))
|
||||
fd = self.cleaned_data['txt']
|
||||
filename = os.path.join(settings.CHARTER_PATH, 'charter-ietf-%s-%s.txt' % (wg.acronym, rev))
|
||||
if fd:
|
||||
# A file was specified. Save it.
|
||||
destination = open(filename, 'wb+')
|
||||
for chunk in fd.chunks():
|
||||
destination.write(chunk)
|
||||
destination.close()
|
||||
else:
|
||||
# No file, save content
|
||||
destination = open(filename, 'wb+')
|
||||
content = self.cleaned_data['content']
|
||||
destination.write(content)
|
||||
destination.close()
|
||||
|
||||
@group_required('Area_Director','Secretariat')
|
||||
def submit(request, name):
|
||||
|
@ -43,7 +52,7 @@ def submit(request, name):
|
|||
raise Http404
|
||||
# Get charter
|
||||
charter = set_or_create_charter(wg)
|
||||
|
||||
|
||||
login = request.user.get_profile()
|
||||
|
||||
if request.method == 'POST':
|
||||
|
@ -70,7 +79,13 @@ def submit(request, name):
|
|||
|
||||
return HttpResponseRedirect(reverse('wg_view_record', kwargs={'name': wg.acronym}))
|
||||
else:
|
||||
form = UploadForm()
|
||||
filename = os.path.join(settings.CHARTER_PATH, 'charter-ietf-%s-%s.txt' % (wg.acronym, wg.charter.rev))
|
||||
try:
|
||||
charter_text = open(filename, 'r')
|
||||
init = dict(content = charter_text.read())
|
||||
except IOError:
|
||||
init = {}
|
||||
form = UploadForm(initial = init)
|
||||
return render_to_response('wgrecord/submit.html',
|
||||
{'form': form,
|
||||
'next_rev': next_revision(wg.charter.rev),
|
||||
|
|
Loading…
Reference in a new issue