예제 #1
0
파일: views.py 프로젝트: EPX/epx2013
def get_excl_fields_acts():
    """
    FUNCTION
    get the list of fields to exclude of the export (from the Act model)
    PARAMETERS
    None
    RETURNS
    excl_fields_acts_ids: list of fields to exclude(from the Act model) [list of strings]
    """
    excl_fields_acts=["id", 'date_doc', "validated", "validated_attendance"]
    return excl_fields_acts
    
    
@login_required
@user_passes_test(lambda u: is_member(u, ["admin", "import_export"]))
def export(request):
    """
    VIEW
    displays the export page -> export all the acts in the db regarding the sorting variable
    TEMPLATES
    export/index.html
    """
    response={}
    
    if request.method=='POST':
        dir_server=settings.MEDIA_ROOT+"/export/"
        file_name="acts.txt"
        #if a file with the same name already exists, we delete it
        if os.path.exists(dir_server+file_name):
            os.remove(dir_server+file_name)
예제 #2
0
파일: forms.py 프로젝트: EPX/epx2013
 def __init__(self, user, *args, **kwargs):
     #show all the different imports to the administrator only
     self.user = user
     super(CSVUploadForm, self).__init__(*args, **kwargs)
     if self.user.is_superuser or is_member(self.user, ["import_export"]):
         self.fields['file_to_import'].choices = get_choices("admin")