Changeset 20

Show
Ignore:
Timestamp:
07/07/06 23:02:21 (3 years ago)
Author:
ploum
Message:

#22 : comments are not displayed in a bug

Yehaah ! Initial comments support. Not as easy as I thought

Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • bug.py

    r18 r20  
    5454                return self.assignee 
    5555 
    56         def setAllComments () : 
    57                 print "hello" 
     56        def setAllComments (self,array) : 
     57                self.comments = array 
    5858 
    59         def getAllComments () : 
    60                 print "hello" 
     59        def getAllComments (self) : 
     60                return self.comments 
    6161 
    62         def addComment () : 
    63                 print "hello" 
     62        def addComment (self,to_add) : 
     63                self.comments.append(to_add) 
     64 
     65        def comNbr(self) : 
     66                return len(self.comments) 
    6467 
    6568         
     
    7376                self.package="" 
    7477                self.assignee="" 
     78                self.comments=[] 
    7579 
    7680class comment: 
    7781 
    78         def __init__(self,n,c,a): 
     82        def __init__(self,n,c,a,t,d): 
    7983                self.nbr=n 
    8084                self.content=c 
    81                 self.author=a    
     85                self.author=a 
     86                self.title=t 
     87                self.date=d      
     88         
     89        def getNumber(self): 
     90                return self.nbr 
     91 
     92        def getContent(self): 
     93                return self.content 
     94 
     95        def getAuthor(self): 
     96                return self.author 
     97 
     98        def getTitle(self): 
     99                return self.title 
     100 
     101        def getDate(self): 
     102                return self.date 
  • bug_template.glade

    r18 r20  
    103103                          <property name="can_focus">True</property> 
    104104                          <property name="show_tabs">True</property> 
    105                           <property name="show_border">True</property> 
     105                          <property name="show_border">False</property> 
    106106                          <property name="tab_pos">GTK_POS_BOTTOM</property> 
    107                           <property name="scrollable">False</property> 
    108                           <property name="enable_popup">False</property> 
     107                          <property name="scrollable">True</property> 
     108                          <property name="enable_popup">True</property> 
    109109 
    110110                          <child> 
     
    265265                                  <property name="can_focus">True</property> 
    266266                                  <property name="label" translatable="yes">label10</property> 
    267                                   <property name="use_underline">False</property> 
    268                                   <property name="use_markup">False</property> 
     267                                  <property name="use_underline">True</property> 
     268                                  <property name="use_markup">True</property> 
    269269                                  <property name="justify">GTK_JUSTIFY_LEFT</property> 
    270270                                  <property name="wrap">True</property> 
     
    347347                        </widget> 
    348348                        <packing> 
    349                           <property name="padding">0</property> 
     349                          <property name="padding">5</property> 
    350350                          <property name="expand">True</property> 
    351351                          <property name="fill">True</property> 
     
    363363 
    364364              <child> 
    365                 <widget class="GtkFrame" id="frame2"> 
     365                <widget class="GtkFrame" id="com_frame"> 
    366366                  <property name="visible">True</property> 
    367367                  <property name="label_xalign">0</property> 
     
    370370 
    371371                  <child> 
    372                     <widget class="GtkAlignment" id="alignment2"> 
     372                    <widget class="GtkLabel" id="dummy_label"> 
    373373                      <property name="visible">True</property> 
     374                      <property name="label" translatable="yes">label10</property> 
     375                      <property name="use_underline">False</property> 
     376                      <property name="use_markup">False</property> 
     377                      <property name="justify">GTK_JUSTIFY_LEFT</property> 
     378                      <property name="wrap">False</property> 
     379                      <property name="selectable">False</property> 
    374380                      <property name="xalign">0.5</property> 
    375381                      <property name="yalign">0.5</property> 
    376                       <property name="xscale">1</property> 
    377                       <property name="yscale">1</property> 
    378                       <property name="top_padding">0</property> 
    379                       <property name="bottom_padding">0</property> 
    380                       <property name="left_padding">12</property> 
    381                       <property name="right_padding">0</property> 
    382  
    383                       <child> 
    384                         <widget class="GtkLabel" id="label4"> 
    385                           <property name="visible">True</property> 
    386                           <property name="label" translatable="yes">Comments not yet implemented</property> 
    387                           <property name="use_underline">False</property> 
    388                           <property name="use_markup">False</property> 
    389                           <property name="justify">GTK_JUSTIFY_LEFT</property> 
    390                           <property name="wrap">False</property> 
    391                           <property name="selectable">False</property> 
    392                           <property name="xalign">0.5</property> 
    393                           <property name="yalign">0.5</property> 
    394                           <property name="xpad">0</property> 
    395                           <property name="ypad">0</property> 
    396                           <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
    397                           <property name="width_chars">-1</property> 
    398                           <property name="single_line_mode">False</property> 
    399                           <property name="angle">0</property> 
    400                         </widget> 
    401                       </child> 
     382                      <property name="xpad">0</property> 
     383                      <property name="ypad">0</property> 
     384                      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
     385                      <property name="width_chars">-1</property> 
     386                      <property name="single_line_mode">False</property> 
     387                      <property name="angle">0</property> 
    402388                    </widget> 
    403389                  </child> 
    404390 
    405391                  <child> 
    406                     <widget class="GtkLabel" id="label3"> 
     392                    <widget class="GtkLabel" id="comments_nbr"> 
    407393                      <property name="visible">True</property> 
    408394                      <property name="label" translatable="yes">&lt;b&gt;Comments&lt;/b&gt;</property> 
     
    427413                </widget> 
    428414                <packing> 
    429                   <property name="padding">0</property> 
     415                  <property name="padding">5</property> 
    430416                  <property name="expand">True</property> 
    431417                  <property name="fill">True</property> 
     418                </packing> 
     419              </child> 
     420 
     421              <child> 
     422                <widget class="GtkLabel" id="label9"> 
     423                  <property name="visible">True</property> 
     424                  <property name="label" translatable="yes">Adding a comment is not yet implemented</property> 
     425                  <property name="use_underline">False</property> 
     426                  <property name="use_markup">False</property> 
     427                  <property name="justify">GTK_JUSTIFY_LEFT</property> 
     428                  <property name="wrap">False</property> 
     429                  <property name="selectable">False</property> 
     430                  <property name="xalign">0.5</property> 
     431                  <property name="yalign">0.5</property> 
     432                  <property name="xpad">0</property> 
     433                  <property name="ypad">0</property> 
     434                  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
     435                  <property name="width_chars">-1</property> 
     436                  <property name="single_line_mode">False</property> 
     437                  <property name="angle">0</property> 
     438                </widget> 
     439                <packing> 
     440                  <property name="padding">10</property> 
     441                  <property name="expand">False</property> 
     442                  <property name="fill">False</property> 
    432443                </packing> 
    433444              </child> 
  • bug_template_self.glade

    r18 r20  
    121121                          <property name="can_focus">True</property> 
    122122                          <property name="show_tabs">True</property> 
    123                           <property name="show_border">True</property> 
     123                          <property name="show_border">False</property> 
    124124                          <property name="tab_pos">GTK_POS_BOTTOM</property> 
    125                           <property name="scrollable">False</property> 
    126                           <property name="enable_popup">False</property> 
     125                          <property name="scrollable">True</property> 
     126                          <property name="enable_popup">True</property> 
    127127 
    128128                          <child> 
     
    283283                                  <property name="can_focus">True</property> 
    284284                                  <property name="label" translatable="yes">label10</property> 
    285                                   <property name="use_underline">False</property> 
    286                                   <property name="use_markup">False</property> 
     285                                  <property name="use_underline">True</property> 
     286                                  <property name="use_markup">True</property> 
    287287                                  <property name="justify">GTK_JUSTIFY_LEFT</property> 
    288288                                  <property name="wrap">True</property> 
     
    365365                        </widget> 
    366366                        <packing> 
    367                           <property name="padding">0</property> 
     367                          <property name="padding">5</property> 
    368368                          <property name="expand">True</property> 
    369369                          <property name="fill">True</property> 
     
    381381 
    382382              <child> 
    383                 <widget class="GtkFrame" id="frame2"> 
     383                <widget class="GtkFrame" id="com_frame"> 
    384384                  <property name="visible">True</property> 
    385385                  <property name="label_xalign">0</property> 
     
    388388 
    389389                  <child> 
    390                     <widget class="GtkAlignment" id="alignment2"> 
     390                    <widget class="GtkLabel" id="dummy_label"> 
    391391                      <property name="visible">True</property> 
     392                      <property name="label" translatable="yes">label10</property> 
     393                      <property name="use_underline">False</property> 
     394                      <property name="use_markup">False</property> 
     395                      <property name="justify">GTK_JUSTIFY_LEFT</property> 
     396                      <property name="wrap">False</property> 
     397                      <property name="selectable">False</property> 
    392398                      <property name="xalign">0.5</property> 
    393399                      <property name="yalign">0.5</property> 
    394                       <property name="xscale">1</property> 
    395                       <property name="yscale">1</property> 
    396                       <property name="top_padding">0</property> 
    397                       <property name="bottom_padding">0</property> 
    398                       <property name="left_padding">12</property> 
    399                       <property name="right_padding">0</property> 
    400  
    401                       <child> 
    402                         <widget class="GtkLabel" id="label4"> 
    403                           <property name="visible">True</property> 
    404                           <property name="label" translatable="yes">Comments not yet implemented</property> 
    405                           <property name="use_underline">False</property> 
    406                           <property name="use_markup">False</property> 
    407                           <property name="justify">GTK_JUSTIFY_LEFT</property> 
    408                           <property name="wrap">False</property> 
    409                           <property name="selectable">False</property> 
    410                           <property name="xalign">0.5</property> 
    411                           <property name="yalign">0.5</property> 
    412                           <property name="xpad">0</property> 
    413                           <property name="ypad">0</property> 
    414                           <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
    415                           <property name="width_chars">-1</property> 
    416                           <property name="single_line_mode">False</property> 
    417                           <property name="angle">0</property> 
    418                         </widget> 
    419                       </child> 
     400                      <property name="xpad">0</property> 
     401                      <property name="ypad">0</property> 
     402                      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
     403                      <property name="width_chars">-1</property> 
     404                      <property name="single_line_mode">False</property> 
     405                      <property name="angle">0</property> 
    420406                    </widget> 
    421407                  </child> 
    422408 
    423409                  <child> 
    424                     <widget class="GtkLabel" id="label3"> 
     410                    <widget class="GtkLabel" id="comments_nbr"> 
    425411                      <property name="visible">True</property> 
    426412                      <property name="label" translatable="yes">&lt;b&gt;Comments&lt;/b&gt;</property> 
     
    445431                </widget> 
    446432                <packing> 
    447                   <property name="padding">0</property> 
     433                  <property name="padding">5</property> 
    448434                  <property name="expand">True</property> 
    449435                  <property name="fill">True</property> 
     436                </packing> 
     437              </child> 
     438 
     439              <child> 
     440                <widget class="GtkLabel" id="label9"> 
     441                  <property name="visible">True</property> 
     442                  <property name="label" translatable="yes">Adding a comment is not yet implemented</property> 
     443                  <property name="use_underline">False</property> 
     444                  <property name="use_markup">False</property> 
     445                  <property name="justify">GTK_JUSTIFY_LEFT</property> 
     446                  <property name="wrap">False</property> 
     447                  <property name="selectable">False</property> 
     448                  <property name="xalign">0.5</property> 
     449                  <property name="yalign">0.5</property> 
     450                  <property name="xpad">0</property> 
     451                  <property name="ypad">0</property> 
     452                  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> 
     453                  <property name="width_chars">-1</property> 
     454                  <property name="single_line_mode">False</property> 
     455                  <property name="angle">0</property> 
     456                </widget> 
     457                <packing> 
     458                  <property name="padding">10</property> 
     459                  <property name="expand">False</property> 
     460                  <property name="fill">False</property> 
    450461                </packing> 
    451462              </child> 
  • bugglade_test.py

    r18 r20  
    55import gtk.glade 
    66import urllib 
    7 from bug import bug 
     7from bug import * 
     8from protocol_launchpadweb import protocol 
    89from BeautifulSoup import BeautifulSoup 
    910# You have to change this if you have another storage 
     
    1112 
    1213 
    13 bugnbr="42" 
    14 nbr=int(bugnbr) 
    15  
    16 zebug = bug(nbr) 
    17  
    18 zeurl="https://launchpad.net/products/malone/+bug/1" 
    19 f= urllib.urlopen(zeurl) 
    20 # ici on a le corps principal 
    21 # faudrait faire un extract pour soulager la mémoire 
    22 soup = BeautifulSoup(f).body.contents[5].div.div 
    23 title = soup.h1.contents[0] 
    24 tbody = soup.findAll('tbody')[0].findAll('td') 
    25 product = tbody[0].a.contents[0] 
    26 status = tbody[1].contents[0] 
    27 importance = tbody[2].contents[0] 
    28 assigned = tbody[3].a.contents[2] 
    29 zebug.setTitle(title) 
    30 zebug.setPackage(product) 
    31 zebug.setStatus(status) 
    32 zebug.setImportance(importance) 
    33 zebug.setAssignee(assigned) 
    34 #need to prettify assigned 
    35 content='' 
    36 p = soup.findAll('div', recursive=0)[1].div.findAll('p', recursive=0) 
    37 for i in p: 
    38         for j in i.contents: 
    39                 content = "%s\n%s"%(content,j) 
    40 zebug.setDescription(content) 
     14bts = protocol() 
     15zebug = bts.retrieveBug(42) 
     16bugnbr = str(zebug.getNbr()) 
    4117 
    4218 
     
    4622bugwidget.signal_autoconnect(dic) 
    4723 
     24widget_comments_nbr = bugwidget.get_widget("comments_nbr") 
     25com_text = "%d comment(s) : "%zebug.comNbr() 
     26widget_comments_nbr.set_text(com_text) 
     27widget_comments = bugwidget.get_widget("com_frame") 
    4828widget_nbr = bugwidget.get_widget("number")  
    4929widget_nbr.set_text(bugnbr) 
     
    6141widget_package.set_text(zebug.getPackage()) 
    6242 
     43#inserting comments 
     44hbox = gtk.VBox(spacing=2) 
     45hbox.show() 
     46for i in zebug.getAllComments(): 
     47        comwidget = gtk.glade.XML("comment.glade") 
     48        comwidget.get_widget("poster").set_text(i.getAuthor()) 
     49        comwidget.get_widget("title").set_text(i.getTitle()) 
     50        comwidget.get_widget("date").set_text(i.getDate()) 
     51        comwidget.get_widget("comment_body").set_text(i.getContent()) 
     52        hbox.add(comwidget.get_widget("comment")) 
     53 
     54 
     55to_remove = bugwidget.get_widget("dummy_label") 
     56widget_comments.remove(to_remove) 
     57widget_comments.add(hbox) 
     58 
    6359#We take the vbox to insert it 
    6460main_widget = bugwidget.get_widget("bug_main") 
  • conseil.py

    r18 r20  
    8989                listing.insert_before(None, ["Evo's bugs", 3, "evolution refresh folder"]) 
    9090                listing.insert_before(None, ["Bug #42", 1, "42"]) 
     91                listing.insert_before(None, ["Content in +text mode", 1, "51835"]) 
     92                listing.insert_before(None, ["Search in bugs+text", 1, "51836"]) 
    9193                renderer = gtk.CellRendererText() 
    9294                column = gtk.TreeViewColumn("title", renderer, text=0) 
     
    209211                bugtemplate = "bug_template.glade" 
    210212                bugwidget = gtk.glade.XML(bugtemplate) 
     213                widget_comments_nbr = bugwidget.get_widget("comments_nbr") 
     214                # TODO : handle nicely plurals 
     215                com_text = "%d comment(s) : "%zebug.comNbr() 
     216                widget_comments_nbr.set_text(com_text) 
     217                widget_comments = bugwidget.get_widget("com_frame") 
    211218                widget_nbr = bugwidget.get_widget("number")  
    212219                title_bugnbr = "Bug #%s :" %bugnbr 
     
    226233                widget_package.set_text(zebug.getPackage()) 
    227234 
     235                #inserting comments 
     236                hbox = gtk.VBox(spacing=2) 
     237                hbox.show() 
     238                for i in zebug.getAllComments(): 
     239                        comwidget = gtk.glade.XML("comment.glade") 
     240                        comwidget.get_widget("poster").set_text(i.getAuthor()) 
     241                        comwidget.get_widget("title").set_text(i.getTitle()) 
     242                        comwidget.get_widget("date").set_text(i.getDate()) 
     243                        comwidget.get_widget("comment_body").set_text(i.getContent()) 
     244                        hbox.add(comwidget.get_widget("comment")) 
     245 
     246                to_remove = bugwidget.get_widget("dummy_label") 
     247                widget_comments.remove(to_remove) 
     248                widget_comments.add(hbox) 
     249 
     250 
    228251                #We take the vbox to insert it 
    229252                main_widget = bugwidget.get_widget("bug_main") 
  • launchpad_test.py

    r18 r20  
    55import gtk.glade 
    66import urllib 
    7 from bug import bug 
     7from bug import * 
    88from BeautifulSoup import BeautifulSoup 
    99# You have to change this if you have another storage 
     
    1111 
    1212 
    13 zeurl="https://launchpad.net/products/malone/+bug/1" 
     13zeurl="https://launchpad.net/bugs/51835" 
    1414f= urllib.urlopen(zeurl) 
     15zebug = bug(42) 
    1516# ici on a le corps principal 
    1617# faudrait faire un extract pour soulager la mémoire 
     
    2122status = tbody[1].contents[0] 
    2223importance = tbody[2].contents[0] 
    23 assigned = tbody[3].a.contents[2] 
    24 #print title 
    25 #print product 
    26 #print status 
    27 #print importance 
     24#assigned = tbody[3].a.contents[2] 
     25print title 
     26print product 
     27print status 
     28print importance 
    2829#need to prettify assigned 
    2930#print assigned 
    30 content='' 
    31 p = soup.findAll('div', recursive=0)[1].div.findAll('p', recursive=0) 
    32 for i in p: 
    33         #print i.renderContents() 
    34         for j in i.contents: 
    35                 jj = j.string 
    36                 if jj != None and jj != "<br />" : 
    37                         print "#############################" 
    38                         newj = jj.strip().replace("&nbsp;"," ") 
    39                         print str(newj) 
    40                         content = "%s\n%s"%(content,newj) 
    41                         #print newj 
    42                 #print j.renderContents() 
    43                 #print "#####################" 
    44         content = "%s\n"%content 
    45 #print content 
     31array_com = soup.findAll('div', recursive=0)[1].findAll('div','boardComment') 
     32print array_com 
     33j = 0 
     34com_counter = 0 
     35for i in array_com : 
     36        details = i.contents[1].findAll('a') 
     37        title = details[0].strong.contents[0] 
     38        poster = details[1].contents[0] 
     39        body = i.contents[3].findAll('p') 
     40        com_counter += 1 
     41        content="" 
     42        for z in body : 
     43                phrase = z.contents[0].string 
     44                new_phrase = phrase.strip().replace("&nbsp;"," ") 
     45                content = "%s\n%s" %(content,new_phrase) 
     46        newcom = comment(com_counter,content,poster,title,"date not implemented") 
     47        zebug.addComment(newcom) 
     48        j += 1 
     49print zebug.comNbr() 
    4650 
    47 #p = soup.p 
    48 #content = p.contents[0] 
    49 #print p.name 
    50 #p = p.next 
    51 #print p 
    52 #p = p.nextSibling.nextSibling 
    53 #while p.name != 'form' : 
    54 #       print p.name 
    55 #       if p.name == 'p' : 
    56 #               content = content+'\n'+p.contents[0] 
    57 #       p = p.next 
    58 #print content 
    59  
    60  
  • protocol_launchpadweb.py

    r18 r20  
    44import gobject 
    55import urllib 
    6 from bug import bug 
     6from bug import * 
    77from BeautifulSoup import BeautifulSoup 
    88# You have to change this if you have another storage 
     
    7575                zebug.setImportance(importance) 
    7676                zebug.setDescription(content) 
     77 
     78                array_com = soup.findAll('div', recursive=0)[1].findAll('div','boardComment') 
     79                j = 0 
     80                com_counter = 0 
     81                for i in array_com : 
     82                        details = i.contents[1].findAll('a') 
     83                        title = details[0].strong.contents[0] 
     84                        poster = details[1].contents[0] 
     85                        body = i.contents[3].findAll('p') 
     86                        com_counter += 1 
     87                        content="" 
     88                        for z in body : 
     89                                phrase = z.contents[0].string 
     90                                new_phrase = phrase.strip().replace("&nbsp;"," ") 
     91                                content = "%s\n%s" %(content,new_phrase) 
     92                        newcom = comment(com_counter,content,poster,title,"00/00/00") 
     93                        zebug.addComment(newcom) 
     94 
    7795                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    7896                return zebug