Changeset efc9355 in indico


Ignore:
Timestamp:
01/24/12 11:13:41 (16 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
a564f1
Parents:
c61253c
git-author:
Alberto Resco Perez <alberto.resco.perez@…> (08/23/11 10:52:14)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (01/24/12 11:13:41)
Message:

[FIX] Apply for participation, move to AJAX

  • The popup is generated by javascript.
  • The application is done with a json call.
  • Closes #908.
Location:
indico
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/services/implementation/conference.py

    r558065 refc9355  
    3333from MaKaC.common.url import ShortURLMapper 
    3434from MaKaC.common import indexes, info 
     35from MaKaC.common.fossilize import fossilize 
    3536 
    3637from MaKaC.conference import ConferenceHolder, ConferenceChair 
     
    4647from MaKaC.common.contextManager import ContextManager 
    4748from MaKaC.user import PrincipalHolder, Avatar, Group, AvatarHolder 
     49from MaKaC.participant import Participant 
    4850 
    4951import datetime 
     
    5961from indico.modules.scheduler import tasks 
    6062from indico.util.i18n import i18nformat 
    61 from MaKaC.participant import Participant 
    62 from MaKaC.common.fossilize import fossilize 
    6363 
    6464 
     
    727727        return [afmDict, cTypesDict] 
    728728 
    729  
    730 class ConferenceParticipationForm(ConferenceDisplayBase): 
    731     def _getAnswer(self): 
    732  
    733         params = {} 
    734  
     729class ConferenceApplyParticipant(ConferenceDisplayBase): 
     730 
     731    def _checkParams(self): 
     732        ConferenceDisplayBase._checkParams(self) 
     733        pm = ParameterManager(self._params) 
     734        self._title = pm.extract("title", pType=str, allowEmpty=True) 
     735        self._familyName = pm.extract("surName", pType=str, allowEmpty=False) 
     736        self._firstName = pm.extract("name", pType=str, allowEmpty=False) 
     737        self._email = pm.extract("email", pType=str, allowEmpty=False) 
     738        self._affiliation = pm.extract("affiliation", pType=str, allowEmpty=True) 
     739        self._address = pm.extract("address", pType=str, allowEmpty=True) 
     740        self._telephone = pm.extract("phone", pType=str, allowEmpty=True) 
     741        self._fax = pm.extract("fax", pType=str, allowEmpty=True) 
     742 
     743    def _getAnswer(self): 
    735744        if self._conf.getStartDate() < timezoneUtils.nowutc() : 
    736             return """This event began on %s, you cannot apply for 
    737                       participation after the event began."""%self._conf.getStartDate() 
     745            raise NoReportError(_("""This event began on %s, you cannot apply for 
     746                                         participation after the event began."""%self._conf.getStartDate()), title=_("Event started")) 
    738747 
    739748        if not self._conf.getParticipation().isAllowedForApplying() : 
    740             return """Participation in this event is restricted to persons invited. 
    741                       If you insist on taking part in this event, please contact the event manager.""" 
    742  
    743         p = wcomponents.WNewPerson() 
    744  
    745         params["formAction"] = str(urlHandlers.UHConfParticipantsAddPending.getURL(self._conf)) 
    746         params["formTitle"] = None 
    747         params["cancelButtonParams"] = """ type="button" id="cancelRegistrationButton" """ 
    748  
    749         params["titleValue"] = "" 
    750         params["surNameValue"] = "" 
    751         params["nameValue"] = "" 
    752         params["emailValue"] = "" 
    753         params["addressValue"] = "" 
    754         params["affiliationValue"] = "" 
    755         params["phoneValue"] = "" 
    756         params["faxValue"] = "" 
    757  
     749            raise NoReportError( _("""Participation in this event is restricted to persons invited. 
     750                                           If you insist on taking part in this event, please contact the event manager."""), title=_("Application restricted")) 
     751        result = {} 
    758752        user = self._getUser() 
    759         if user is not None : 
    760             params["titleValue"] = user.getTitle() 
    761             params["surNameValue"] = user.getFamilyName() 
    762             params["nameValue"] = user.getName() 
    763             params["emailValue"] = user.getEmail() 
    764             params["addressValue"] = user.getAddress() 
    765             params["affiliationValue"] = user.getAffiliation() 
    766             params["phoneValue"] = user.getTelephone() 
    767             params["faxValue"] = user.getFax() 
    768  
    769             params["disabledTitle"] = params["disabledSurName"] = True 
    770             params["disabledName"] = params["disabledEmail"] = True 
    771             params["disabledAddress"] = params["disabledPhone"] = True 
    772             params["disabledFax"] = params["disabledAffiliation"] = True 
    773  
    774         return p.getHTML(params) 
     753        pending = Participant(self._conf, user) 
     754        if user is None : 
     755            pending.setTitle(self._title) 
     756            pending.setFamilyName(self._familyName) 
     757            pending.setFirstName(self._firstName) 
     758            pending.setEmail(self._email) 
     759            pending.setAffiliation(self._affiliation) 
     760            pending.setAddress(self._address) 
     761            pending.setTelephone(self._telephone) 
     762            pending.setFax(self._fax) 
     763        participation = self._conf.getParticipation() 
     764        if participation.alreadyParticipating(pending) != 0: 
     765            raise NoReportError(_("The participant can not be added to the meeting because there is already a participant with the email address '%s'." 
     766                                % pending.getEmail()),title=_('Already registered participant')) 
     767        elif participation.alreadyPending(pending)!=0: 
     768            raise NoReportError(_("The participant can not be added to the meeting because there is already a pending participant with the email address '%s'." 
     769                                % pending.getEmail()),title=_('Already pending participant')) 
     770        else: 
     771            if participation.addPendingParticipant(pending): 
     772                if participation.getAutoAccept(): 
     773                    result["msg"] = _("The request for participation has been accepted") 
     774                    if participation.displayParticipantList() : 
     775                        result["listParticipants"] = participation.getPresentParticipantListText() 
     776                else: 
     777                    result["msg"] = _("The participant identified by email '%s' has been added to the list of pending participants" 
     778                                    % pending.getEmail()) 
     779            else: 
     780                return NoReportError(_("The participant cannot be added."), title=_("Error")) 
     781        return result 
    775782 
    776783class ConferenceProtectionUserList(ConferenceModifBase): 
     
    843850    def _handleGet(self): 
    844851        return self._target.getAccessController().getContactInfo() 
    845  
    846852 
    847853class ConferenceAlarmSendTestNow(ConferenceModifBase): 
     
    11911197#    "getFields": ConferenceGetFields, 
    11921198    "getFieldsAndContribTypes": ConferenceGetFieldsAndContribTypes, 
    1193     "getParticipationForm": ConferenceParticipationForm, 
     1199    "participation.applyParticipant": ConferenceApplyParticipant, 
    11941200    "protection.getAllowedUsersList": ConferenceProtectionUserList, 
    11951201    "protection.addAllowedUsers": ConferenceProtectionAddUsers, 
  • indico/MaKaC/webinterface/pages/conferences.py

    r4e85d60 refc9355  
    11001100        vars["firstDay"] = self._firstDay 
    11011101        vars["lastDay"] = self._lastDay 
     1102        vars["currentUser"] = self._rh._aw.getUser() 
    11021103 
    11031104        return vars 
  • indico/MaKaC/webinterface/rh/conferenceDisplay.py

    r8fc14a refc9355  
    10501050 
    10511051 
    1052 class RHConfParticipantsAddPending(RHConferenceDisplay): 
    1053     _uh = urlHandlers.UHConfParticipantsAddPending 
    1054  
    1055     def _process( self ): 
    1056         params = self._getRequestParams() 
    1057         errorList = [] 
    1058         infoList = [] 
    1059         if params.has_key("ok") : 
    1060             user = self._getUser() 
    1061             pending = Participant(self._conf, user) 
    1062             if user is None : 
    1063                 pending.setTitle(params.get("title","")) 
    1064                 pending.setFamilyName(params.get("surName","")) 
    1065                 pending.setFirstName(params.get("name","")) 
    1066                 pending.setEmail(params.get("email","")) 
    1067                 pending.setAffiliation(params.get("affiliation","")) 
    1068                 pending.setAddress(params.get("address","")) 
    1069                 pending.setTelephone(params.get("phone","")) 
    1070                 pending.setFax(params.get("fax","")) 
    1071             participation = self._conf.getParticipation() 
    1072             if participation.alreadyParticipating(pending) != 0 or participation.alreadyPending(pending) != 0: 
    1073                 errorList.append("There is already a participant with the email address '%s' in this meeting." 
    1074                                  % pending.getEmail()) 
    1075             else: 
    1076                 if participation.addPendingParticipant(pending): 
    1077                     if participation.getAutoAccept(): 
    1078                         infoList.append(_("The request for participation has been accepted")) 
    1079                     else: 
    1080                         infoList.append("The participant identified by email '%s' has been added to the list of pending participants" 
    1081                                     % pending.getEmail()) 
    1082                 else: 
    1083                     errorList.append(_("The participant cannot be added.")) 
    1084  
    1085         if infoList: 
    1086             self._reqParams["infoMsg"] = infoList 
    1087         if errorList: 
    1088             self._reqParams["errorMsg"] = errorList 
    1089  
    1090         return RHConferenceDisplay._process(self) 
    1091  
    1092  
    10931052class RHConfParticipantsRefusal(RHConferenceBaseDisplay): 
    10941053    _uh = urlHandlers.UHConfParticipantsRefusal 
  • indico/MaKaC/webinterface/tpls/events/include/EventDetails.tpl

    raba8f4 refc9355  
    22<%namespace name="common" file="Common.tpl"/> 
    33 
    4 <table class="eventDetails"> 
     4<table class="eventDetails" id="eventDetails"> 
    55<tbody> 
    66% if conf.getDescription(): 
    7 <tr> 
     7<tr id="eventDescription"> 
    88    <td class="leftCol">Description</td> 
    99    <td>${common.renderDescription(conf.getDescription())}</td> 
     
    1212 
    1313% if participants: 
    14 <tr> 
     14<tr id="eventParticipants"> 
    1515    <td class="leftCol">Participants</td> 
    16     <td>${participants}</td> 
     16    <td id="eventListParticipants">${participants}</td> 
    1717</tr> 
    1818% endif 
     
    8080        Want to participate? 
    8181        <span class="fakeLink" id="applyLink">Apply here</span> 
    82         <script type="text/javascript"> 
    83             $E('applyLink').observeClick(function(){new ApplyForParticipationPopup("${conf.getId()}")}); 
    84         </script> 
    8582    </td> 
    8683</tr> 
     
    111108</tbody> 
    112109</table> 
     110<script type="text/javascript"> 
     111    IndicoUI.executeOnLoad(function(){ 
     112        var onSuccess = function(result){ 
     113            if(result.msg){ 
     114                (new AlertPopup($T("Success"),result.msg)).open(); 
     115            } 
     116            if (result.listParticipants){ 
     117                if( $("#eventParticipants").length==0){ 
     118                    var trParticipants=$(Html.tr({id:"eventParticipants"}, 
     119                            Html.td({class:"leftCol"},$T("Participants")), 
     120                            Html.td({id:"eventListParticipants"},"")).dom); 
     121                    if ($("#eventDescription").length==0){ 
     122                        $("#eventDetails").prepend(trParticipants); 
     123                    }else{ 
     124                        $("#eventDescription").after(trParticipants); 
     125                    } 
     126                } 
     127                $("#eventListParticipants").text(result.listParticipants).effect("highlight",{},3000); 
     128            } 
     129        }; 
     130        var userData = {}; 
     131        var allowEdit = true; 
     132        % if currentUser: 
     133            allowEdit = false; 
     134            userData["id"] = '${currentUser.getId()}'; 
     135            userData["title"] = '${currentUser.getTitle()}'; 
     136            userData["surName"] = '${currentUser.getFamilyName()}'; 
     137            userData["name"] = '${currentUser.getName()}'; 
     138            userData["email"] = '${currentUser.getEmail()}'; 
     139            userData["address"] = '${currentUser.getAddress()}'; 
     140            userData["affiliation"] = '${currentUser.getAffiliation()}'; 
     141            userData["phone"] = '${currentUser.getTelephone()}'; 
     142            userData["fax"] = '${currentUser.getFax()}'; 
     143        % endif 
     144            $('#applyLink').click(function(){new ApplyForParticipationPopup('${conf.getId()}','event.participation.applyParticipant', 
     145                    $T('Apply for participation'), userData, onSuccess, allowEdit);}); 
     146    }); 
     147</script> 
  • indico/MaKaC/webinterface/urlHandlers.py

    r9a8115 refc9355  
    16551655class UHConfParticipantsNewPending( URLHandler ): 
    16561656    _relativeURL = "confModifParticipants.py/newPending" 
    1657  
    1658 class UHConfParticipantsAddPending( URLHandler ): 
    1659     _relativeURL = "confModifParticipants.py/addPending" 
    16601657 
    16611658 
  • indico/htdocs/confModifParticipants.py

    rcb55f2 refc9355  
    7474    return conferenceDisplay.RHConfParticipantsNewPending( req ).process( params ) 
    7575 
    76 def addPending( req, **params ): 
    77     return conferenceDisplay.RHConfParticipantsAddPending( req ).process( params ) 
    78  
    7976def invitation( req, **params ): 
    8077    return conferenceDisplay.RHConfParticipantsInvitation( req ).process( params ) 
  • indico/htdocs/js/indico/Core/Dialogs/Base.js

    ra95c41 refc9355  
    5858                        self._error(error); 
    5959                    } else { 
    60                         self._success(response); 
    6160                        killProgress(); 
    6261                        self.close(); 
     62                        self._success(response); 
    6363                    } 
    6464                } 
  • indico/htdocs/js/indico/Display/Dialogs.js

    r9033fd refc9355  
    1 type("ApplyForParticipationPopup", ["ExclusivePopup", "PreLoadHandler"], { 
    2     _preload: [ 
    3         function(hook) { 
    4             var self = this; 
    5             indicoRequest("event.getParticipationForm", {"conference": self.confId}, 
    6                 function(result, error){ 
    7                     if (error) { 
    8                         IndicoUtil.errorReport(error); 
    9                     } 
    10                     else { 
    11                         self.formHtml = result; 
    12                         hook.set(true); 
    13                     } 
    14                 } 
    15             ); 
     1type("ApplyForParticipationPopup", ["ServiceDialogWithButtons"], { 
     2    _success: function(response) { 
     3        this.onSuccess(response); 
     4    }, 
     5 
     6    _save: function(response) { 
     7        var self = this; 
     8        if(self.parameterManager.check()){ 
     9            self.request(self.userData); 
    1610        } 
    17     ], 
     11    }, 
     12 
     13    _drawButtons: function(){ 
     14        var self = this; 
     15        var saveButton = Html.input('button', {style: {marginRight: pixels(3)}}, $T('Ok')); 
     16        var cancelButton = Html.input('button', {style: {marginLeft: pixels(3)}}, $T('Cancel')); 
     17        saveButton.observeClick(function(){ 
     18            self._save(); 
     19        }); 
     20        cancelButton.observeClick(function(){ 
     21            self.close(); 
     22        }); 
     23       return Html.div({}, saveButton, cancelButton); 
     24    }, 
     25 
     26    _drawUserEditable: function() { 
     27        var self = this; 
     28        return IndicoUtil.createFormFromMap( 
     29                [ 
     30                 [$T('Title'), $B(Html.select({}, Html.option({}, ""), Html.option({value:'Mr.'}, $T("Mr.")), Html.option({value:'Mrs.'}, $T("Mrs.")), Html.option({value:'Ms.'}, $T("Ms.")), Html.option({value:'Dr.'}, $T("Dr.")), Html.option({value:'Prof.'}, $T("Prof."))), self.userData.accessor('title'))], 
     31                 [$T('Family Name'), $B(self.parameterManager.add(Html.edit({style: {width: '200px'}}), 'text', false), self.userData.accessor('surName'))], 
     32                 [$T('First Name'), $B(self.parameterManager.add(Html.edit({style: {width: '200px'}}), 'text', false), self.userData.accessor('name'))], 
     33                 [$T('Affiliation'), $B(Html.edit({style: {width: '200px'}}), self.userData.accessor('affiliation'))], 
     34                 [$T('Email'),  $B(self.parameterManager.add(Html.edit({style: {width: '200px'}}), 'email', true), self.userData.accessor('email'))], 
     35                 [$T('Address'), $B(Html.textarea({style: {width: '200px'}}), self.userData.accessor('address'))], 
     36                 [$T('Telephone'), $B(Html.edit({style: {width: '150px'}}), self.userData.accessor('phone'))], 
     37                 [$T('Fax'), $B(Html.edit({style: {width: '150px'}}), self.userData.accessor('fax'))], 
     38             ]); 
     39    }, 
     40 
     41    _drawUserNotEditable: function() { 
     42        var self = this; 
     43        return IndicoUtil.createFormFromMap( 
     44                [ 
     45                 [$T('Title'), self.userData.get("title")], 
     46                 [$T('Last Name'),self.userData.get("surName")], 
     47                 [$T('First Name'), self.userData.get("name")], 
     48                 [$T('Email'),self.userData.get("email")], 
     49                 [$T('Address'),self.userData.get("address")], 
     50                 [$T('Affiliation'),self.userData.get("affiliation")], 
     51                 [$T('Telephone'),self.userData.get("phone")], 
     52                 [$T('Fax'),self.userData.get("fax")] 
     53             ]); 
     54    }, 
    1855 
    1956    draw: function() { 
    20         var div = Html.div({}); 
    21         div.dom.innerHTML = this.formHtml; 
    22         div.dom.style.minWidth = '350px'; 
    23         div.dom.style.maxWidth = '500px'; 
    24         return this.ExclusivePopup.prototype.draw.call(this, div); 
     57        var self = this; 
     58        self.parameterManager = new IndicoUtil.parameterManager(); 
     59        var tabWidget = null; 
     60        if(this.allowEdit){ 
     61            tabWidget = self._drawUserEditable(); 
     62        } 
     63        else{ 
     64            tabWidget = self._drawUserNotEditable(); 
     65        } 
     66        return this.ServiceDialogWithButtons.prototype.draw.call(this, tabWidget, this._drawButtons()); 
     67    } 
     68}, 
     69 
     70    function(confId, method, title, userData, onSuccess, allowEdit) { 
     71        this.onSuccess = any(onSuccess,positive); 
     72        this.confId = confId; 
     73        this.userData = $O(userData); 
     74        this.allowEdit = any(allowEdit, true); 
     75        var self = this; 
     76        self.userData.set("confId",self.confId); 
     77        this.ServiceDialogWithButtons(Indico.Urls.JsonRpcService, method, userData, title, function() {self.close();}); 
     78        self.open(); 
     79    } 
     80); 
     81 
     82 
     83type("BasicEmailPopup", ["ExclusivePopupWithButtons"],{ 
     84 
     85    _drawButtons: function(){ 
     86        var self = this; 
     87        var sendButton = Html.input('button', null, $T("Send")); 
     88        sendButton.observeClick(function(){ 
     89            self.sendFunction(); 
     90        }); 
     91        var cancelButton = Widget.button(command(function() {self.close();}, $T("Cancel"))); 
     92        var buttonDiv = Html.div({style:{textAlign:"center"}}, sendButton, cancelButton) 
     93        return buttonDiv; 
    2594    }, 
    26      
    27     postDraw: function() { 
     95 
     96    _drawRTWidget: function(){ 
     97 
     98        var self = this; 
     99        // Text editor with default message 
     100        self.rtWidget = new ParsedRichTextEditor(700, 400, 'IndicoMinimal'); 
     101        self.rtWidget.set(self.defaultText); 
     102    }, 
     103 
     104    _drawTop: function(){ 
     105        var self = this; 
     106        return Html.div({}, self._drawFromAddress(), self._drawToAddress(), self._drawSubject()); 
     107    }, 
     108 
     109    _drawWidget: function(){ 
     110        var self = this; 
     111        self._drawRTWidget(); 
     112        return Html.div({}, self._drawTop(), self.rtWidget.draw(), self._drawLegends()); 
     113    }, 
     114 
     115    _drawLegends: function(){ 
     116        var self = this; 
     117        if(_.size(self.legends) == 0){ 
     118            return null; 
     119        } 
     120        var legendFields = []; 
     121        for(legend in self.legends){ 
     122            legendFields.push(Html.tr({}, Html.td({}, "{"+legend+"} :"), Html.td({}, self.legends[legend]))); 
     123        } 
     124        return Html.div({style:{marginLeft: '20px', 
     125                         fontStyle:'italic', 
     126                         color:'gray'} 
     127                  }, 
     128                  Html.div({style:{fontWeight:'bold'}}, $T("Legend:")), 
     129                  Html.table({},legendFields)); 
     130    }, 
     131 
     132    draw: function(){ 
    28133        var self = this; 
    29134 
    30         this.ExclusivePopup.prototype.postDraw.call(this); 
    31         $E('cancelRegistrationButton').observeClick(function() {self.close()}); 
     135        return this.ExclusivePopupWithButtons.prototype.draw.call( 
     136                self, 
     137                self._drawWidget(), 
     138                self._drawButtons() 
     139                ); 
    32140    } 
    33     }, 
    34      
    35     function(confId) { 
    36         this.confId = confId; 
    37         var self = this; 
    38         this.PreLoadHandler( 
    39                 self._preload, 
    40                 function() { 
    41                     self.open(); 
    42                 }); 
    43         this.execute(); 
    44          
    45         this.ExclusivePopup("Apply for participation", function() {return true;}) 
     141}, 
     142function(title, confTitle, confId, subject, defaultText, legends){ 
     143    var self = this; 
     144    self.confTitle = confTitle; 
     145    self.confId = confId; 
     146    self.defaultText = any(defaultText,""); 
     147    self.subject = new WatchObject(); 
     148    $B(self.subject.accessor(), subject); 
     149    self.legends = any(legends,{}); 
    46150 
    47     } 
     151    this.ExclusivePopupWithButtons(title); 
     152} 
    48153); 
Note: See TracChangeset for help on using the changeset viewer.