Initial attempt at prof/import.py data import
authorW. Trevor King <wking@drexel.edu>
Wed, 30 Jun 2010 15:30:15 +0000 (11:30 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 30 Jun 2010 15:35:09 +0000 (11:35 -0400)
sitecore/prof/__init__.py
sitecore/prof/export_mysql.py
sitecore/prof/import.py

index 7b24e72c4e40172f478e91396d32d2d9b61ba286..0995faca1585d3b15bae72afd9e79e719c61b0a1 100644 (file)
@@ -106,10 +106,11 @@ class Graduation (AttributeHolder):
     fields = ['college', 'field', 'title', 'year']
 
 class Contact (AttributeHolder):
-    fields = ['office', 'email', 'website', 'phone', 'lab', 'lab_phone']
+    fields = ['office', 'email', 'website', 'groupsite',
+              'phone', 'lab', 'lab_phone']
 
 class Bio (AttributeHolder):
-    fields = ['specialization', 'publications', 'profile', 'cv']
+    fields = ['category', 'specialization', 'publications', 'profile', 'cv']
 
 class Professor (AttributeHolder):
     fields = ['name', 'title', 'graduations', 'contact', 'bio']
@@ -147,3 +148,30 @@ class Professor (AttributeHolder):
                     if m in degrees:
                         degrees.remove(m)
         return '|'.join(degrees)
+
+    def colleges(self):
+        titles = self.degrees().split('|')
+        return '|'.join([g.college for g in self.graduations
+                         if g.title in titles])
+
+    def program(self):
+        "Sub-field(s)"
+        if self.contact.group_site == None:
+            return 'Physics'
+        #TODO: group to sub-field logic
+
+    def sites(self):
+        if self.contact.groupsite == None:
+            return ('<a href="%s">%s</a>'
+                    % (self.contact.website, self.contact.website))
+        return ('Group Website: <a href="%s">%s</a>|Personal Website: <a href="%s">%s</a>'
+                % (self.contact.groupsite, self.contact.groupsite,
+                   self.contact.website, self.contact.website))
+
+    def lab_contact(self):
+        "Lab Name, Lab Phone"
+        if self.contact.lab != None:
+            assert self.contact.lab_phone != None, unicode(self.name)
+            return '%s, %s' % (self.contact.lab, self.contact.lab_phone)
+        assert self.contact.lab_phone == None, unicode(self.name)
+        return None
index 152eb9551b137ce60b96610a04b23d09cf31a198..e484fc850ec1f47b7a8557d014aa77f80c3fe376 100644 (file)
@@ -172,7 +172,7 @@ Where the relevant categories are
                 )
             p.title = prof['position']
             if prof['position1'] != None:
-                p.title += '%s' % prof['position1']
+                p.title += '|%s' % prof['position1']
             p.graduations = []
             degrees = []
             if prof['degrees'] != None:
@@ -195,12 +195,14 @@ Where the relevant categories are
                 office=prof['office'],
                 email=prof['email'],
                 website=prof['personalpage'],
+                groupsite=prof['grouppage'],
                 phone=prof['phone'],
                 lab=prof['lab'],
                 lab_phone=prof['labphone'],
                 )
             p.bio = Bio(
-                specialization=prof['research'], # prof['grouppage']
+                role=prof['category'],
+                specialization=prof['research'],
                 publications=None,
                 profile=prof['profile'],
                 cv=None,
index 6faefcb2a63064697d69665bb46d83f88a534cd7..77afc41054c30bee056c762301b899a43783fc5f 100644 (file)
@@ -50,11 +50,44 @@ class ProfessorAdder (object):
         self.s.expand_nav_section('facultyDirectory')
 
     def __call__(self, prof):
-        self.create_prof_page(prof)
-        TODO
-
-    def create_prof_page(self, prof):
         name = '%s %s' % (prof.name.first_middle, prof.name.last)
+        self.create_prof_page(name)
+        self.lock_section()
+        settings = [
+            ('Degrees:', prof.degrees()),
+            ('College:', prof.colleges()),
+            ('Program:', prof.program()),
+            ('Office:', prof.contact.office),
+            ('Specialization:', prof.bio.specialization),
+            ('Research Interests:', ''),
+            ('Personal Site:', prof.sites()),
+            ('Title:', prof.title),
+            ('First Name:', prof.name.first_middle),
+            ('Last Name:', prof.name.last),
+            ('Bio:', '<p>\n%s\n%</p>'+prof.bio.profile.replace(
+                    '\n', '\n</p>\n<p>\n')),
+            ('Headshot:', ('/Images/physics/headshots/%s'
+                           % name.lower().replace('.','').replace(' ','_'))),
+            ('Email:', prof.contact.email),
+            ('Phone:', prof.contact.phone),
+            ('Fax:', prof.lab_contact()),
+            ('Page Title - This shows in the tab and title bar of the brower -- Google rates it highly:', name),
+            ("Menu Title - This shows in the menus and navigation blocks -- it's usually a shorted version of the page title:", name),
+            ("Breadcrumb Title - This shows in the breadcrumb trail -- it's usually a very short version of the page title:", name),
+            ("See Also title - Other items that refer to this one will use this text:", name),
+            ]
+        for field_name,value in settings:
+            if value == None:
+                value = ''
+            granddad,field = s.find_field(field_name)
+            field.clear()
+            field.send_keys(value)
+        #granddad,field = s.find_field('Headshot:')
+        #granddad.find_element_by_link_text('Properties')
+        # TODO, set width/height
+        s.publish_section('Added/updated Prof. %s' % prof.name.last)
+
+    def create_prof_page(self, name):
         self.s.open_nav_section(name)
         return
         self.s.open_nav_section('Copy of Shyamalendu Bose')
@@ -80,6 +113,12 @@ class ProfessorAdder (object):
                            % (popup, current_window))
         self.s.open_nav_section(name)
 
+    def lock_section(self):
+        try:
+            self.s.lock_section()
+        except NoSuchElementException, e:
+            self.s.logger.info("can't lock %s (already locked?), skipping" % raw_name)
+
 
 def main(argv):
     import optparse