87 | | #balance |
88 | | if entry.LimitBy and (entry.LimitBy.lower() == "balance") : |
89 | | if balance == 0.0 : |
90 | | if entry.OverCharge > 0 : |
91 | | datelimit = "DENY" |
92 | | reached = "+B" |
93 | | else : |
94 | | # overcharging by a negative or nul factor means user is always allowed to print |
95 | | # TODO : do something when printer prices are negative as well ! |
96 | | datelimit = "" |
97 | | reached = "-B" |
98 | | elif balance < 0 : |
99 | | datelimit = "DENY" |
100 | | reached = "+B" |
101 | | elif balance <= self.tool.config.getPoorMan() : |
102 | | datelimit = "WARNING" |
103 | | reached = "?B" |
104 | | else : |
105 | | datelimit = "" |
106 | | reached = "-B" |
107 | | |
108 | | #balance-then-quota |
109 | | elif entry.LimitBy and (entry.LimitBy.lower() == "balance-then-quota") : |
110 | | if balance <= 0 : |
111 | | if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : |
112 | | datelimit = "DENY" |
113 | | elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : |
114 | | datelimit = "DENY" |
115 | | elif quota.DateLimit is not None : |
116 | | now = DateTime.now() |
117 | | datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) |
118 | | if now >= datelimit : |
119 | | datelimit = "QUOTA_DENY" |
120 | | else : |
121 | | datelimit = "" |
122 | | reached = ( ((datelimit == "DENY" ) and "+B") or "-Q") |
123 | | datelimit = ( ((datelimit == "QUOTA_DENY") and "DENY") or datelimit) |
124 | | elif balance <= self.tool.config.getPoorMan() : |
125 | | if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : |
126 | | datelimit = "WARNING" |
127 | | elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : |
128 | | datelimit = "WARNING" |
129 | | elif quota.DateLimit is not None : |
130 | | now = DateTime.now() |
131 | | datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) |
132 | | if now >= datelimit : |
133 | | datelimit = "QUOTA_DENY" |
134 | | else : |
135 | | datelimit = "" |
136 | | reached = ( ((datelimit == "WARNING" ) and "?B") or "+Q") |
137 | | datelimit = ( ((datelimit == "QUOTA_DENY") and "WARNING") or datelimit) |
138 | | else : |
139 | | datelimit = "" |
140 | | reached = "-B" |
141 | | |
142 | | #Quota-then-balance |
143 | | elif entry.LimitBy and (entry.LimitBy.lower() == "quota-then-balance") : |
144 | | if (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : |
145 | | datelimit = "DENY" |
146 | | elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : |
147 | | datelimit = "DENY" |
148 | | elif quota.DateLimit is not None : |
149 | | now = DateTime.now() |
150 | | datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) |
151 | | if now >= datelimit : |
152 | | datelimit = "DENY" |
153 | | else : |
154 | | datelimit = "" |
155 | | |
156 | | reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" |
157 | | |
158 | | if (datelimit == "DENY") and (reached == "-Q") and (balance > self.tool.config.getPoorMan()) : |
159 | | datelimit = "" |
160 | | reached = "-B" |
161 | | else : |
162 | | reached = (((datelimit == "DENY") and (self.tool.config.getPoorMan() < balance ) and "-B") or reached) |
163 | | if (datelimit == "DENY") and (self.tool.config.getPoorMan() < balance) : |
164 | | datelimit = "" |
165 | | reached = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "?B") or reached) |
166 | | datelimit = (((datelimit == "DENY") and (0.0 < balance <= self.tool.config.getPoorMan()) and "WARNING") or datelimit) |
167 | | |
168 | | #Quota |
169 | | else : |
| 87 | if (not entry.LimitBy) or (entry.LimitBy.lower() == "quota") : |