Ejemplo n.º 1
0
def preview():

  try:
    t_pid = int(p.form.getvalue('p_pid', 0))
  except:
    p['errors']['p_pid'] = 'Bildiri numarası rakamlardan oluşmalı.'
  else:
    q = """SELECT Count(*)
           FROM proposals
           WHERE pid=%s"""
    if p.db.scalar_query(q, t_pid):
      p['errors']['p_pid'] = 'Bu numaraya sahip bir bildiri var.'
    
  if not len(p.form.getvalue('p_title', '')):
    p['errors']['p_title'] = 'Başlık boş bırakılamaz.'

  if not len(p.form.getvalue('p_summary', '')):
    p['errors']['p_summary'] = 'Özet boş bırakılamaz.'

  if not len(p.form.getvalue('p_content', '')):
    p['errors']['p_content'] = 'Bildiri detayları boş bırakılamaz.'

  # Hiç hata yoksa...
  if not len(p['errors']):
    p.template = 'new_proposal.view.tpl'

    p['proposal'] = {
                     'title': html_escape(p.form.getvalue("p_title", "")),
                     'summary': nl2br(html_escape(p.form.getvalue("p_summary", ""))),
                     'content': formatText(p.form.getvalue("p_content", ""))
                     }
  else:
    p.template = 'new_proposal.tpl'
Ejemplo n.º 2
0
def preview():
  try:
    p['pid'] = int(p.form.getvalue('pid'))
    p['version'] = p.form.getvalue('version')
  except:
    p.http.redirect('error.py?tag=proposal_not_found')

  # Bildiri sorumlusu mu?
  q = """SELECT Count(*)
         FROM rel_maintainers
         WHERE
           uid=%s AND pid=%s"""
  if not p.db.scalar_query(q, (p['session']['uid'], p['pid'])):
    p.http.redirect('error.py?tag=not_maintainer')

  p.template = 'edit_proposal.tpl'

  if not len(p.form.getvalue('p_title', '')):
    p['errors']['p_title'] = 'Başlık boş bırakılamaz.'

  if not len(p.form.getvalue('p_summary', '')):
    p['errors']['p_summary'] = 'Özet boş bırakılamaz.'

  if not len(p.form.getvalue('p_content', '')):
    p['errors']['p_content'] = 'Bildiri detayları boş bırakılamaz.'

  if int(p.form.getvalue('p_version', 0)) not in range(1, 4):
    p['errors']['p_version'] = 'Değişiklik derecesi geçerli değil.'

  if not len(p.form.getvalue('p_changelog', '')):
    p['errors']['p_changelog'] = 'Sürüm notları boş bırakılamaz.'

  # Hiç hata yoksa...
  if not len(p['errors']):
    p.template = 'edit_proposal.view.tpl'

    p['proposal'] = {
                     'title': html_escape(p.form.getvalue("p_title", "")),
                     'summary': nl2br(html_escape(p.form.getvalue("p_summary", ""))),
                     'content': formatText(p.form.getvalue("p_content", ""))
                     }
  else:
    p.template = 'edit_proposal.tpl'
Ejemplo n.º 3
0
def index():
  try:
    pid = int(p.form.getvalue('pid'))
    version = p.form.getvalue('version', 0)
  except:
    p.template = 'viewproposal.error.tpl'
    return

  if not version:
    q = """SELECT
             version
           FROM proposals_versions
           WHERE
             pid=%s
           ORDER BY vid DESC
           LIMIT 1"""
    version = p.db.scalar_query(q, pid)

  if pid and version:
    q = """SELECT
             proposals.pid,
             proposals_versions.version,
             proposals_versions.title,
             proposals_versions.summary,
             proposals_versions.content
           FROM proposals
             INNER JOIN proposals_versions
               ON proposals.pid=proposals_versions.pid
           WHERE
             proposals.pid=%s AND
             proposals_versions.version=%s"""
    row = p.db.row_query(q, (pid, version))

    if row:

      p['proposal'] = {
                       'pid': row[0],
                       'version': html_escape(row[1]),
                       'title': html_escape(row[2]),
                       'summary': nl2br(html_escape(row[3])),
                       'content': formatText(row[4])
                       }

      # Sürüm geçmişi
      q = """SELECT
               proposals_versions.version,
               proposals_versions.changelog
             FROM proposals_versions
             WHERE
               pid=%s
             ORDER BY vid DESC"""
      rows = p.db.query(q, pid)
      
      p['versions'] = []
      for i in rows:
        l = {
             'version': i[0],
             'log': i[1]
             }
        p['versions'].append(l)

      # Sorumlular
      q = """SELECT
               users.uid,
               users.username
             FROM users
               INNER JOIN rel_maintainers
                 ON rel_maintainers.uid=users.uid
             WHERE
               rel_maintainers.pid=%s
             ORDER BY users.username ASC"""
      rows = p.db.query(q, pid)

      p['is_maintainer'] = 0
      p['maintainers'] = []
      for i in rows:
        if 'uid' in p['session'] and p['session']['uid'] == i[0]:
          p['is_maintainer'] = 1
        l = {
             'uid': i[0],
             'user': i[1]
             }
        p['maintainers'].append(l)
    
      # Yorumlar
      q = """SELECT
               proposals_comments.cid,
               users.username,
               proposals_comments.content
             FROM proposals_comments
               INNER JOIN users
                 ON users.uid=proposals_comments.uid
             WHERE proposals_comments.pid=%s"""
      rows = p.db.query(q, pid)

      p['comments'] = []
      for i in rows:
        l = {
             'user': i[1],
             'comment': nl2br(html_escape(i[2]))
             }
        p['comments'].append(l)

      # Yorum ekleme
      p['may_comment'] = 'proposals_comment' in p['acl']

      p.template = 'viewproposal.tpl'
    else:
      p.template = 'viewproposal.error.tpl'
  else:
    p.template = 'viewproposal.error.tpl'