app/soc/views/helper/access.py
changeset 2433 0ba41e115dbc
parent 2380 f23025455742
child 2447 dae6715a2f19
equal deleted inserted replaced
2432:636dfd5381c2 2433:0ba41e115dbc
    39 from soc.logic import rights as rights_logic
    39 from soc.logic import rights as rights_logic
    40 from soc.logic.helper import timeline as timeline_helper
    40 from soc.logic.helper import timeline as timeline_helper
    41 from soc.logic.models.club_admin import logic as club_admin_logic
    41 from soc.logic.models.club_admin import logic as club_admin_logic
    42 from soc.logic.models.club_member import logic as club_member_logic
    42 from soc.logic.models.club_member import logic as club_member_logic
    43 from soc.logic.models.document import logic as document_logic
    43 from soc.logic.models.document import logic as document_logic
       
    44 from soc.logic.models.survey import logic as survey_logic
    44 from soc.logic.models.host import logic as host_logic
    45 from soc.logic.models.host import logic as host_logic
    45 from soc.logic.models.mentor import logic as mentor_logic
    46 from soc.logic.models.mentor import logic as mentor_logic
    46 from soc.logic.models.org_admin import logic as org_admin_logic
    47 from soc.logic.models.org_admin import logic as org_admin_logic
    47 from soc.logic.models.organization import logic as org_logic
    48 from soc.logic.models.organization import logic as org_logic
    48 from soc.logic.models.program import logic as program_logic
    49 from soc.logic.models.program import logic as program_logic
  1509 
  1510 
  1510     return
  1511     return
  1511 
  1512 
  1512   @allowSidebar
  1513   @allowSidebar
  1513   @allowDeveloper
  1514   @allowDeveloper
       
  1515   def checkIsSurveyReadable(self, django_args, key_name_field=None):
       
  1516     """Checks whether a survey is readable.
       
  1517 
       
  1518     Args:
       
  1519       django_args: a dictionary with django's arguments
       
  1520       key_name_field: key name field
       
  1521     """
       
  1522 
       
  1523     if key_name_field:
       
  1524       key_name = django_args[key_name_field]
       
  1525       survey = survey_logic.getFromKeyNameOr404(key_name)
       
  1526     else:
       
  1527       survey = survey_logic.getFromKeyFieldsOr404(django_args)
       
  1528 
       
  1529     self.checkMembership('read', survey.prefix,
       
  1530                          survey.read_access, django_args)
       
  1531 
       
  1532   @denySidebar
       
  1533   @allowDeveloper
       
  1534   def checkIsSurveyWritable(self, django_args, key_name_field=None):
       
  1535     """Checks whether a survey is writable.
       
  1536 
       
  1537     Args:
       
  1538       django_args: a dictionary with django's arguments
       
  1539       key_name_field: key name field
       
  1540     """
       
  1541 
       
  1542     if key_name_field:
       
  1543       key_name = django_args[key_name_field]
       
  1544       survey = survey_logic.getFromKeyNameOr404(key_name)
       
  1545     else:
       
  1546       survey = survey_logic.getFromKeyFieldsOr404(django_args)
       
  1547 
       
  1548     self.checkMembership('write', survey.prefix,
       
  1549                          survey.write_access, django_args)
       
  1550 
       
  1551 
       
  1552   @allowSidebar
       
  1553   @allowDeveloper
  1514   def checkIsDocumentReadable(self, django_args, key_name_field=None):
  1554   def checkIsDocumentReadable(self, django_args, key_name_field=None):
  1515     """Checks whether a document is readable by the current user.
  1555     """Checks whether a document is readable by the current user.
  1516 
  1556 
  1517     Args:
  1557     Args:
  1518       django_args: a dictionary with django's arguments
  1558       django_args: a dictionary with django's arguments