0

I'm working on making a job application page with Django 1.3 (I know that I should update but that part is out of my hands) with apache through mod_wsgi and am running into issue when users try to view uploaded files such as resumes in the submitted applications.

Here is the View for the page trying to access the file

def apply(request, ann_id):
user = UserManager(request)
okay = user.isOk(request)
if not okay:
    raise Http404
username = user.data.get('userName')

if user.data.get('employeer') != "Company":
    return render_to_response('lobbs/cannotApply.html', locals())

announcement = get_object_or_404(Announcements, id=ann_id)

validation_errors = []
applicantBen_error = ''
orgBen_error = ''
ast_error = ''
grade_error = ''
fpl_error = ''
resume_error = ''
reviewedSOD_error = ''
understand_error = ''

if request.method == 'POST':
    form = LookupForm(request.POST, request.FILES)

    if form.is_valid():
        if announcement.type_id in [1,2,3]:
            applicantBen = form.data.get('benefitApplicant','')
            orgBen = form.data.get('benefitOrg','')
            if not applicantBen:
                applicantBen_error = ERROR_BENEFIT_APPLICANT
                validation_errors.append(applicantBen_error)
            if not orgBen:
                orgBen_error = ERROR_BENEFIT_ORG
                validation_errors.append(orgBen_error)
        if announcement.type_id in [4,5]:
            resumeFile = ''
            try:
                resumeFile = request.FILES['resume']
            except KeyError:
                resumeFile = ''
            reviewSOD = form.data.get('reviewedSOD','')
            if not resumeFile:
                resume_error = ERROR_RESUME
                validation_errors.append(resume_error)
            if not reviewSOD:
                reviewedSOD_error = ERROR_REVIEWED_SOD
                validation_errors.append(reviewedSOD_error)
        if announcement.type_id == 4:
            astTitle = form.data.get('title','')
            grade = form.data.get('grade','')
            fpl = form.data.get('fpl','')
            if not astTitle:
                ast_error = ERROR_AST
                validation_errors.append(ast_error)
            if not grade:
                grade_error = ERROR_GRADE
                validation_errors.append(grade_error)
            if not fpl:
                fpl_error = ERROR_FPL
                validation_errors.append(fpl_error)
            if announcement.tempPromotion:
                understand = form.data.get('understandTempPromotion','')
                if not understand:
                    understand_error = ERROR_UNDERSTAND
                    validation_errors.append(understand_error)
        if announcement.type_id == 5:
            verify = form.data.get('verifyCurrPos','')
            if not verify:
                verify_error = ERROR_VERIFY
                validation_errors.append(verify_error)
        if not validation_errors:
            newLookupObject = form.save(commit=False)
            newLookupObject.announcement = announcement
            newLookupObject.announceNum = announcement.announceNum
            newLookupObject.userID = user.data.get('id')
            newLookupObject.save()

            sender = u"EMAIL"
            subject = u"LOBBS - Application Received"
            textMail = u"Hello %s,<br><br>Your application for %s (%s), has been entered into LOBBS.  You will be notified of a selection by the person selecting applicants.<br><br><br>%s" % (user.data.get('userName'), announcement.title,announcement.announceNum, LOBBS_URL)
            recipients = [user.data.get('email')]
            msg = EmailMessage(subject, textMail, sender, recipients)
            msg.content_subtype = "html"
            msg.send()

            return HttpResponseRedirect(reverse('lobbs.views.index'))

else:
    #data = { 'announcement': announcement, 'announceNum': announcement.announceNum, 'userID': user.data.get('id') }
    #form = LookupForm(data)
    form = LookupForm(initial={'userName': user.data.get('userName'), 'phone': user.data.get('phone'),
                               'email': user.data.get('email'), 'org': user.data.get('org'), 'announcement': announcement,
                               'announceNum': announcement.announceNum, 'userID': user.data.get('id')})

return render_to_response('lobbs/apply.html', locals(), context_instance=RequestContext(request))

And here is the template that it is using

{% extends "base.html" %}
{% block header %}
  {% include 'lobbs/apply_header.html' %}
{% endblock %}
{% block main_content %}
{% load url from future %}

  <br />
  <div align="center">
  <form enctype="multipart/form-data"  name="software"  action="{% url 'lobbs_apply' ann_id=announcement.id %}"  method="post" onreset ="return confirm('Erase ALL data and start over?')">
  {% csrf_token %}
  <table width = "600" cellspacing = "0" cellpadding = "2" align = "center" border = 0>
    <tr>
      <td bgcolor = "#eaeaea" colspan="2">
        <font color="red">
          {% for field in form %}
            {% if field.errors %}
               {{ field.label_tag }} - {{ field.errors }}
            {% endif %}
          {% endfor %}
          {% if validation_errors %}
            <ul>
              {% for item in validation_errors %}
                <li>{{ item  }}</li>
              {% endfor %}
            </ul>
          {% endif %}
        </font>
      </td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>Opp No</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ announcement.announceNum }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>Title</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ announcement.title }}</td>
    </tr>
    {% if announcement.type.id == 1 or announcement.type.id == 2 or announcement.type.id == 3 %}
      <tr>
        <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>Description</strong></th>
        <td bgcolor = "#eaeaea" valign="top" align="left">{{ announcement.description }}</td>
      </tr>
    {% else %}
      <tr>
        <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{% if announcement.type.id != 5 %}Statement of Duties / {% endif %}Position Description</strong></th>
        <td bgcolor = "#eaeaea" valign="top" align="left">{% if announcement.statementOfDuties%} <a href="{{ announcement.statementOfDuties.url }}">{% if announcement.type.id != 5 %}Statement of Duties / {% endif %}Position Description</a>{% endif %}</td>
      </tr>
    {% endif %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>Type</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ announcement.type }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.userName.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.userName }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.phone.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.phone }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.email.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.email }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.org.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.org }}</td>
    </tr>
    {% if announcement.type_id = 4 %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.title.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.title }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right" nowrap="nowrap"><strong>{{ form.grade.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.grade }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.fpl.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.fpl }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right">&nbsp;</th>
      <td bgcolor = "#eaeaea" valign="top" align="left">SNIP</td>
    </tr>
    {% endif %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.supApproval.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.supApproval }}</td>
    </tr>
    {% if announcement.type_id = 1 or announcement.type_id = 2 or announcement.type_id = 3 %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.benefitApplicant.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.benefitApplicant }}</td>
    </tr>
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.benefitOrg.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.benefitOrg }}</td>
    </tr>
    {% endif %}
    {% if announcement.type_id = 4 or announcement.type_id = 5 %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right">&nbsp;</th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.reviewedSOD }} {{ form.reviewedSOD.label_tag }}</td>
    </tr>
    {% endif %}
    {% if announcement.type_id = 4 %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right">&nbsp;</th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.understandTempPromotion }} {{ form.understandTempPromotion.label_tag }}</td>
    </tr>
    {% endif %}
    {% if announcement.type_id = 5 %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right">&nbsp;</th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.verifyCurrPos }} {{ form.verifyCurrPos.label_tag }}</td>
    </tr>
    {% endif %}
    <tr>
      <th bgcolor = "#eaeaea" valign = "top" align = "right"><strong>{{ form.resume.label_tag }}</strong></th>
      <td bgcolor = "#eaeaea" valign="top" align="left">{{ form.resume }}<br /><font color="red">*</font> LOBBS is not intended to collect Personally Identifiable Information (PII) from any users.  Applicants are highly discouraged from including any PII in documents uploaded into the system.</td>
    </tr>
    <tr>
      <td colspan="2"><INPUT TYPE = "submit" NAME = "Operation" VALUE = "Apply"> <INPUT TYPE = "reset" VALUE = "Reset"></td>
    </tr>
  </table>

  </form>
  </div>
  <br />

{% endblock %}

When clicking the link to the file the browser says that the webpage is not available, but the url follows the path to where the file is stored on the server. Any way to fix this that I am missing?

1 Answer 1

0

For whatever reason the issue was that the server was behind in updating it's files, and ignored the changes implemented to fix the issue for a few days. Afterwards it worked perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.