Posts

Django admin interface to display aggregates -

i want use django admin interface display aggregates of data in model. ex: model has following fields [employee name, salary, month] want aggregate table fields [month, total_salary_paid, cumulative_of_month_salaries_paid]. how do ?? have searched internet didn't find way it..any reference or guidance help here's snippet recent project of mine. adds column in admin "are there entries in m2m related table?" , "what's count of entries in m2m related table?". similar things other aggregate functions django offers. from django.db.models import count django.contrib import admin class expertmodeladmin(admin.modeladmin): def num_companies(self, obj): """# of companies expert has.""" return obj.num_companies num_companies.short_description = "# companies" def has_video(self, obj): """does expert have video?""" return bool(obj.has_v...

c++ - Setting class member to null in destructor -

in this page there's piece of code: class mystring { private: char *m_pchstring; int m_nlength; public: mystring(const char *pchstring="") { // find length of string // plus 1 character terminator m_nlength = strlen(pchstring) + 1; // allocate buffer equal length m_pchstring = new char[m_nlength]; // copy parameter our internal buffer strncpy(m_pchstring, pchstring, m_nlength); // make sure string terminated m_pchstring[m_nlength-1] = '\0'; } ~mystring() // destructor { // need deallocate our buffer delete[] m_pchstring; // set m_pchstring null in case m_pchstring = 0; } char* getstring() { return m_pchstring; } int getlength() { return m_nlength; } }; in destructor, writer sets m_pchstring null , says in case. can happen if don't set null? have deallocated specified memory , class members killed u...

Issue creation and commenting via email in Redmine -

i'm redmine user , administrator. want configure redmine allow issue creation , commenting via email. need configure in such way reads emails standard input. (not imap, pop3, or email server) can please suggest suitable way , required code segment this? redmine have rake tasks query pop3 , imap mail accounts. see redmine wiki

c# - How to set focus on a textbox when I close another Form? -

i have 2 forms, form1 , form2. form2 opened button located in form1. want when close form2 x(cross) button in upper right corner of window, focus set textbox1 of form1. regarding ?? try private void button1_click(object sender, eventargs e) { form2 f = new form2(); f.show(); f.formclosed += f_formclosed; } void f_formclosed(object sender, formclosedeventargs e) { textbox1.focus(); }

php - How to fetch specific elements from an array and create a new array based on the comparison of an array key's value? -

my question may sound confusing people. in fact it's quite simple one. let me clear scenario. i've array titled $test_result_data follows: array ( [0] => array ( [test_pack_id] => 8ed32f6479a0169db3531d3366996d35 [test_pack_name] => cpt free samples [test_pack_desc] => package contains free sample test of 30 minutes containing 30 questions - fundamentals of accounting, mercantile law, general economics , quantitative aptitude. perfect discover beauty of online exam preparation. [test_pack_type_id] => 7 [test_pack_image] => [test_pack_validity_year] => 0 [test_pack_validity_month] => 0 [test_pack_validity_days] => 3 [test_pack_plan] => free [test_pack_price] => 0.00 [test_pack_no_tests] => 0 [test_pack_publish] => yes [test_pack_code] => [test_pack_sol...

iphone - Usage of captive network -

sorry english. want app use captive network. idea when user try connect captive portal network app open instead od relative web sheet. know have use function cnsetsupportedssids(), don't understand how implement it. in advance! this code have wrote. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { nsarray *array = [nsarray arraywithobjects:@"ssid of network",nil]; bool ok = cnsetsupportedssids((__bridge cfarrayref) array); if(ok) { nslog(@"completed %lu",(unsigned long)[array count]); } else { nslog(@"failed"); } // override point customization after application launch. return yes; }

.htaccess - How to force htaccess to index.php if no file or parameters specified -

i want if user enters site url without specifying file or parameters site.com or site.com/ , should redirected site.com/index.php if enter file site.com/somefile.php or give parameters site.com/?param=val , htaccess should not , let run. in .htaccess, add line: directoryindex index.php this way apache index.php requests yoursite.com & yoursite.com/. there no need add rewrite condition rule! plus, servers don't allow rewrite conditions. in wamp, rewrite disabled default.